Compare commits
3 Commits
ccaa8c7c9e
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ceac876aa3 | |||
| 3302abaa66 | |||
| b203ad131f |
+4
-1
@@ -10,5 +10,8 @@
|
||||
|
||||
[env:uno]
|
||||
platform = atmelavr
|
||||
board = uno
|
||||
board = sparkfun_promicro16
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
https://github.com/DFRobot/DFRobotDFPlayerMini
|
||||
arduino-libraries/Servo@^1.3.0
|
||||
|
||||
+12
-21
@@ -1,31 +1,22 @@
|
||||
#include <Arduino.h>
|
||||
#define LED 13
|
||||
#include <Servo.h>
|
||||
|
||||
void displayMicros();
|
||||
void displayMillis();
|
||||
#define SERVO_PIN6 6
|
||||
#define READ_ANALOG8 8
|
||||
|
||||
Servo MYSERVO;
|
||||
int ANGLE = 0;
|
||||
|
||||
// Setup Section
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
pinMode(LED, OUTPUT);
|
||||
attachInterrupt(0, displayMicros, RISING); // #1
|
||||
attachInterrupt(1, displayMillis, RISING);
|
||||
}
|
||||
|
||||
void displayMicros() {
|
||||
Serial.write("micros() = ");
|
||||
Serial.println(micros());
|
||||
}
|
||||
|
||||
void displayMillis() {
|
||||
Serial.write("millis() = ");
|
||||
Serial.println(millis());
|
||||
MYSERVO.attach(SERVO_PIN6);
|
||||
// pinMode(READ_ANALOG8, INPUT);
|
||||
}
|
||||
|
||||
// Loop Section
|
||||
void loop() {
|
||||
digitalWrite(LED, HIGH);
|
||||
delay(500);
|
||||
digitalWrite(LED, LOW);
|
||||
delay(500);
|
||||
ANGLE = analogRead(READ_ANALOG8);
|
||||
ANGLE = map(ANGLE, 0, 1023, 0, 180);
|
||||
MYSERVO.write(ANGLE);
|
||||
delay(10);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user