<< Back

Exercise 2.2 - Sensors

f) Traffic light warning system

This is the console. All output created with writeLog() is shown here.

Enter warning and critical thresholds for the temperature and press "Set thresholds". When the critical threshold is exceeded, the LED will turn red and the hardware button starts blinking. The user needs to act by pressing the button.

Warning threshold:

Critical threshold:


script.js

This is the JavaScript code behind the above application.