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