Hi folks,
Workshop 2 will be in Clark A201 starting at 7pm tonight (Wednesday November, 28). Make sure you bring a fully charged laptop and your kit.
We will have breadboards for sale and will be handing out the servos that are a part of your kit. If you haven't picked up your kit yet, we will have that available for you.
The mini-project for this workshop is the Pirate Security System. We will go over analog to digital voltage converters, voltage division, and serial connections as well as the serial monitor.
We will also talk about the first Mini Design Competition (MiniDC) that takes place over Winter Break.
void setup(){
ReplyDeleteSerial.begin(9600); //Start serial
}
int attempt = 0; //The attempt
char password[3] = {'a','c','b'}; //The password to get booty (oo la la)
char passAttempt[3]; //The user's power attempt
void loop(){
int voltage = analogRead(0); //get the analog voltage
if (voltage > 100){ //check to see if stylus is touching
passAttempt[attempt] = voltToChar(voltage); //get character for pass
attempt++;//scale attempt by one
Serial.println(voltToChar(voltage)); //see what is happening
}
if (attempt == 3){
attempt = 0; //set attempt attempt to zeros
if (passAttempt[0] == password[0] &&
passAttempt[1] == password[1] &&
passAttempt[2] == password[2]){ //see if passwords mach
Serial.println("Arr matey! Ye may enter and claim yer booty!"); //password correct
}
else Serial.println("None may enter here! Get yer booty somewhere else!"); //Password incorrect
}
while(analogRead(0) > 100){} //Wait for user to take off stylus
delay(50); //short delay for debounce
}
char voltToChar(int voltage){
if (voltage > 450)
return 'a';
else if (voltage > 300)
return 'b';
else return 'c';
}
Hey Austin, what was the code that we used to read the voltage initially to determine the ranges for the code above?
ReplyDeleteexcellent post i read it with my friends it continue more better for best wealthy knowledge thanks
ReplyDeletehttp://homeworkhelp.freetzi.com
homework help
mgt 311 final exam
eco 365 final exam
eco 372 final exam
acc 561 final exam