Embedded Programming

Pedestrian Crossing & Traffic Light System


Program


#define gives a name to a constant value. The syntax is "#define Name value".
In this case, the value is the pin number.

setup() is a function that will only run once.
It initialize the variables, pin modes and libraries.

loop() is a function that allows the program to be execute repeatedly. The if statement checks if the
push button is pressed, if it is pressed, it will execute the statements in the braces.

The for loop allows the statements to be executed multiple times. The loop ends when the conditions are
not met. The syntax is "for (initialization; condition; increment){}". The statements in the else clause is executed
if the conditions for the if statements are not met.


Program Simulation (Tinkercad)

All Files

Click here to download files.