Morse Code Project
Traffic Light Activity
Servo Motors
Code for the Continuous Servo MotorAs per the diagram above:
0 degrees goes anti clockwise 90 degrees goes in no direction 180 degrees goes in a clock wise direction This looks like servo.write(0); servo.write(90); servo.write(180); |
Task - Make the spin forward exactly 3 cycles forward and then 3 cycles back and stop for 3 seconds
Use the Sweep example for this... Examples --> Servo --> seep |
Ultra Sonic Sensor
The Code
|
long duration;
int distance; void setup() { pinMode(5, OUTPUT); pinMode(6, INPUT); Serial.begin(9600); } void loop() { digitalWrite(5, LOW); delayMicroseconds(2); digitalWrite(5, HIGH); delayMicroseconds(10); digitalWrite(5, LOW); duration = pulseIn(6, HIGH); distance = duration*0.034/2; Serial.print("Distance: "); Serial.println(distance); } |
Now the Additional Tasks
|
You Might need this code:
if ( distance < 10){ } else { } |