/*
TouchTweet.ino
Touch Tweet: Arduino Sketch
Copyright 2014 Pavlos Iliopoulos, techprolet.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include
#include "rgb_lcd.h"
rgb_lcd lcd;
const int colorR = 0;
const int colorG = 0;
const int colorB = 255;
const int pinButton = 7; // pin of button define here
boolean touchStarted = false;
void setup()
{
pinMode(pinButton, INPUT); // set button INPUT
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setRGB(0,0,0);
// Print a message to the LCD.
lcd.print("Status:");
delay(1000);
}
void loop()
{
lcd.setCursor(0, 1);
if(digitalRead(pinButton)) // when button is pressed
{
if (!touchStarted) {
touchStarted = true;
lcd.print ("touch!");
lcd.setRGB(colorR, colorG, colorB);
system("echo $(date '+%Y %b %d %H:%M:%S') Touch! $(hostname) >> /tmp/arduino.log");
}
}
else
{
touchStarted = false;
lcd.setRGB(0,0,0);
lcd.print (" ");
}
delay(10);
}