8 changed files with 95 additions and 3 deletions
@ -0,0 +1,51 @@ |
|||||
|
|
||||
|
#include <Wire.h> |
||||
|
#include <Adafruit_PWMServoDriver.h> |
||||
|
|
||||
|
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(); |
||||
|
|
||||
|
#define SERVOMIN 150 // this is the 'minimum' pulse length count (out of 4096)
|
||||
|
#define SERVOMAX 600 // this is the 'maximum' pulse length count (out of 4096)
|
||||
|
|
||||
|
String inputString = ""; // a String to hold incoming data
|
||||
|
boolean stringComplete = false; // whether the string is complete
|
||||
|
|
||||
|
void setup() { |
||||
|
Serial.begin(9600); |
||||
|
|
||||
|
pwm.begin(); |
||||
|
pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
|
||||
|
|
||||
|
delay(10); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void loop() { |
||||
|
// print the string when a newline arrives:
|
||||
|
if (stringComplete) { |
||||
|
Serial.println(inputString); |
||||
|
// clear the string:
|
||||
|
inputString = ""; |
||||
|
stringComplete = false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void serialEvent() { |
||||
|
while (Serial.available()) { |
||||
|
// get the new byte:
|
||||
|
char inChar = (char)Serial.read(); |
||||
|
// add it to the inputString:
|
||||
|
inputString += inChar; |
||||
|
// if the incoming character is a newline, set a flag so the main loop can
|
||||
|
// do something about it:
|
||||
|
if (inChar == '\n') { |
||||
|
stringComplete = true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void svuota(){ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
After Width: | Height: | Size: 44 KiB |
@ -0,0 +1,14 @@ |
|||||
|
void makePicture() { |
||||
|
saveFrame("data/shot.gif"); |
||||
|
img = loadImage("shot.gif"); |
||||
|
ephSerial(); |
||||
|
} |
||||
|
|
||||
|
void backupFrame() { |
||||
|
// save picture with results for backup |
||||
|
saveFrame("history/shot_" + |
||||
|
nf(year(), 4) + nf(month(), 2) + nf(day(), 2) + "_" + |
||||
|
nf(hour(), 2) + nf(minute(), 2) + nf(second(), 2) + |
||||
|
".gif"); |
||||
|
println("color count image saved"); |
||||
|
} |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 44 KiB |
@ -0,0 +1,4 @@ |
|||||
|
|
||||
|
void ephSerial() { |
||||
|
port.write(colorValues); |
||||
|
} |
Loading…
Reference in new issue