// C++ code // const int LedPin=2; //the number of the LED pin on my board const int buttonPin=7; int buttonState=0; //variable for reading pushbutton int counter; int times=0; void setup() { pinMode(LedPin, OUTPUT); pinMode(buttonPin, INPUT); } void loop() { //the following is going to spell out HELLO in Morse Code when the button is pressed buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (buttonState == HIGH) { //H= dot dot dot dot times=4; for (counter =0; counter < times; ++counter) { digitalWrite(LedPin, HIGH); delay(100); // Wait for 100 millisecond(s) digitalWrite(LedPin, LOW); delay(500); // Wait for 500 millisecond(s) } delay(1000); // Wait for 1000 millisecond(s) between letters //E = dot digitalWrite(LedPin, HIGH); delay(100); // Wait for 100 millisecond(s) digitalWrite(LedPin, LOW); delay(500); // Wait for 500 millisecond(s) delay(1000); // Wait for 1000 millisecond(s) between letters //L= dot dash dot dot TWICE for 2 L's times=2; for (counter=0; counter< times; ++counter) { digitalWrite(LedPin, HIGH); delay(100); // Wait for 100 millisecond(s) digitalWrite(LedPin, LOW); delay(500); // Wait for 500 millisecond(s) digitalWrite(LedPin, HIGH); delay(500); // Wait for 500 millisecond(s) digitalWrite(LedPin, LOW); delay(500); // Wait for 500 millisecond(s) digitalWrite(LedPin, HIGH); delay(100); // Wait for 100 millisecond(s) digitalWrite(LedPin, LOW); delay(500); // Wait for 500 millisecond(s) digitalWrite(LedPin, HIGH); delay(100); // Wait for 100 millisecond(s) digitalWrite(LedPin, LOW); delay(500); // Wait for 500 millisecond(s) delay(1000); // Wait for 1000 millisecond(s) between letters } // O=dash dash dash times=3; for (counter =0; counter < times; ++counter) { digitalWrite(LedPin, HIGH); delay(500); // Wait for 500 millisecond(s) digitalWrite(LedPin, LOW); delay(500); // Wait for 500 millisecond(s) } delay(1000); // Wait for 1000 millisecond(s) between letters } }