/*
CTC GO! CORE MODULE
LESSON 05 - Showing messages on PC
This sketch is written to accompany Activity 1 in Lesson 05 of the CTC GO! core module
void setup()
{
// initialize digital serial communication at 9600baud.
Serial.begin(9600);
}
void loop()
{
//Printing a sentnce every second
Serial.println("Hello Mate!");
delay(1000);
}
*/
/*
CTC GO! CORE MODULE
LESSON 05 - Showing messages on PC
This sketch is written to accompany Activity 2 in Lesson 05 of the CTC GO! core module
*/
// initialising the pins and other variables.
int button = 2;
int button_state = 0;
int counter = 101;
void setup()
{
Serial.begin(9600);
// Setting up the pins as OUTPUTS.
pinMode(button, INPUT);
}
void loop()
{
button_state = digitalRead(button);
if (button_state == HIGH)
{
counter -= 1;
delay(500);
Serial.print("counter value = ");
Serial.println(counter);
//Reset counter when it reaches 0
if (counter == 0)
{
counter = 100;
}
}
}