CEED Camp Instructor Reseources Blog
Tuesday, June 5, 2018
Toll Gate sample Arduino code
#include <Servo.h>
Servo JimServo;
void setup() {
// put your setup code here, to run once:
JimServo.attach(6); // My white wire is connected to Pin 6.
Serial.begin(9600);
}
char gate = 0;
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()>0) { // is a character other than 0 available?
gate=Serial.read();
}
if (gate=='d'){ // if a user has typed a d
Serial.println("\t Gate is down");
JimServo.write(0);
delay(2000);
}
if (gate=='u'){ // if a user has typed a u
Serial.println("\t Gate is now OPEN");
JimServo.write(180);
delay(2000);
}
}
Servo JimServo;
void setup() {
// put your setup code here, to run once:
JimServo.attach(6); // My white wire is connected to Pin 6.
Serial.begin(9600);
}
char gate = 0;
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()>0) { // is a character other than 0 available?
gate=Serial.read();
}
if (gate=='d'){ // if a user has typed a d
Serial.println("\t Gate is down");
JimServo.write(0);
delay(2000);
}
if (gate=='u'){ // if a user has typed a u
Serial.println("\t Gate is now OPEN");
JimServo.write(180);
delay(2000);
}
}
Arduino Kits for Consideration
Four options for your consideration.

The official Arduino kit:
This is the kit provided by Arduino, and it includes the very useful book. AMAZON LINK
Option 1. Minimalist programmer

Option 2. Beginning tinkerer and programmer

AMAZON LINK

The best value, however, is likely this Elegoo Uno kit with a much greater variety of sensors and actuators, for just $10 more:
AMAZON LINK

A similarly good value, this kit will keep even avid tinkerers busy for years of learning. It's about double the current price of Option 3, at $59.
AMAZON LINK
Welcome to our online resources!
The resources in this blog are available for any interested teacher. To learn more, contact me at JimE@vt.edu.
Subscribe to:
Posts (Atom)