Showing Data on the Maker Screen

Interacting with the real world is one of the most fun things about using Maker Board to code. Maker Screen can display readings from all sorts of sensors.

In this example, you'll see how to take a light reading from a light sensor. If you don't have a light sensor, you can plug a button into A5 and GND and press it to change the reading. Here's the code.

/*Using a Maker Screen, learn to display a sensor value with code. * Be sure that you have the library from Let's Start Coding * to complete this program. */ // include the library code: #include "MakerScreenXVI.h" //Create an object for the MakerScreenXVI library named 'lcd' MakerScreenXVI lcd; void setup() { //Always type the lcd's name followed by .begin() in the void setup() lcd.begin(); //.begin() method 'turns on' a number of settings in the library pinMode(A5,INPUT_PULLUP); //Set a light sensor as an INPUT_PULLUP on A5 and GND } void loop() { lcd.print(analogRead(A5)); //the analogRead result is immediately printed. delay(1000); //pause one second between prints. Change this number to see what happens. lcd.clear();//wipe the screen after each print. Remove this line to see the effect. } // Try to create a label for the reading, such as "Light Level:" on the screen // (c) 2017 Let's Start Coding. License:

This is just one example of using data to show on the Maker Screen. The lcd.print() method can print a variable value, a direct reading (like analogRead(A5)), or a string of numbers or characters.

You should be able to display almost any reading you can take with Maker Board. If you get confused about how to take readings or how to interpret them in code, check out some of the Base Kit projects like "Press Button to Turn on LED", which is a simple example of taking a reading from a button. 

Don't forget that you can use the lcd.print() method to help you troubleshoot, too. If, for example you want to use a light reading to trigger the backlight, you can print the light reading to the screen as you carry the screen around, finding out what your local light readings are.