5_3 Screen Print Constant Variable

Print a Constant Variable on the Screen

Code

The code in the editor below is ready to run! Plug Code Lab Mini in to your computer's USB port, make sure that your Code Lab Mini Screen Add-On (sold separately) is attached, and hit 'Upload Your Code!' to see what it does. Change something in the code, like a delay or pin number. Try to add something new to the program - it's yours to tinker with! You can always press the 'Restore' button to return the code to the working example.

If you haven't set up your Code Lab Mini Screen Add-On yet, visit Chapter 0 to watch a video showing you how to do that.


/* Use a variable to decide how quickly an LED blinks 'Print' the value of the variable on the Code Lab Mini screen add-on Notice how the computer swaps out the variable's name for its number value */ #include "CLMiniScreen.h" //A code library enables new functions to be used with the screen CLMiniScreen lcd; //the library name is followed by the 'name' you give the LCD screen. Here it is 'lcd' int wait = 1000; //variable named 'wait' that is an integer (whole number, no decimals), with a value of 1000 void setup() { lcd.begin(); //.begin() 'sets up' the screen. pinMode(8,OUTPUT); //LED light } void loop(){ digitalWrite(8,HIGH); //turn on the LED lcd.print(wait); //Print the value of the variable on the screen delay(wait); //delay for 'wait' amount of time, 1000 milliseconds (1 second) digitalWrite(8,LOW); //turn off the LED lcd.clear(); //Clear the values form the screen delay(wait); //delay for 'wait' amount of time before restarting the loop } // (c) 2023 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense
 

Walkthrough Video

Watch the video for a line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

Challenges

Coming Soon!