You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
728 B
C++
46 lines
728 B
C++
/*
|
|
*/
|
|
int toggle_2;
|
|
int toggle_1;
|
|
const byte NUMBER_OF_NAMES = 5;
|
|
char *names[NUMBER_OF_NAMES] = {
|
|
"BOB0",
|
|
"BOB1",
|
|
"BOB2",
|
|
"BOB3",
|
|
"BOB4",};
|
|
void setup() {
|
|
// initialize serial communications (for debugging only):
|
|
Serial.begin(9600);
|
|
|
|
}
|
|
|
|
|
|
void loop() {
|
|
toggle_2 = analogRead(2);
|
|
if (toggle_2 < 250) {
|
|
Serial.println(" cat");
|
|
}
|
|
|
|
else if(toggle_2 >250 && toggle_2 <500){
|
|
Serial.println(" dog");
|
|
}
|
|
|
|
else if(toggle_2 >500 && toggle_2 <750){
|
|
Serial.println(" mouse");
|
|
}
|
|
|
|
else if(toggle_2 >750){
|
|
Serial.println(" cockroach");
|
|
}
|
|
delay(250);
|
|
|
|
{
|
|
randomSeed(analogRead(0));
|
|
Serial.print("Hello ");
|
|
Serial.print(names[random(0,NUMBER_OF_NAMES)]);
|
|
}
|
|
|
|
// delay in between reads for stability
|
|
}
|