COI - Boredom Meter
Hardware
- RGB backlight LCD
- Grove Button
- Intel Edison
- computer
- 2 mini usb cords
- 2 jumpers
- static mat
Grove starter kit plus with the Intel Edison
the RGB back light LCD belongs in the D3 port. And the button belongs in the D7 port. There are two usb cords hanging out of the back. There are two jumpers connecting the button and the back light. There is a static mat with an alligator clip grounding you to the mat.
Software
Open the Arduino Edison IDE and use the following code:
#include<br><wire.h></wire.h>
#include <rgb_lcd.h></rgb_lcd.h>
rgb_lcd lcd;
const int buttonPin = 3;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int numPresses = 0;
boolean buttonWasJustDown = false;
int rVal = 0;
int gVal = 0;
int bVal = 0;
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Boredom Measure:");
delay(1000);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop()
{
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
if(buttonWasJustDown==false){
numPresses = numPresses+1;
buttonWasJustDown = true;
rVal = random(0,256);
gVal = random(0,256);
bVal = random(0,256);
lcd.setRGB(rVal, gVal, bVal);
}
} else {
lcd.setRGB(255, 255, 255);
buttonWasJustDown = false;
}
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(numPresses);
delay(100);
}
Verify and Upload the Code.
Result
Your finished product is a “Boredom Meter” that counts the number of times you push the button. It changes the color of the LCD screen every time you push the button. This same technology can be used by people with disabilities to signal for help, or it can be used in the workplace as a signal between workers or in a factory line. Finally, the counting ability can be used for counting how many times a door has been opened.
Experience
There are a number of pitfalls that should be avoided when doing this project.
- Always use the static mat, as charges can accumulate on the electronics or your body if not properly grounded, and this can damage the electronics.
- Make sure the ports on the Grove Starter Kit Plus Base Shield are the same as the ones used in the picture. If not, the address used in the code will not be able to access the button.
- Check the connections on the components to ensure failure is not due to a hardware problem.