LED project
-
- Posts: 35
- Joined: Thu Dec 12, 2013 7:58 am
Re: LED project
sorry double post due to lag
Last edited by normski001 on Sat Dec 14, 2013 8:23 pm, edited 2 times in total.
-
- Posts: 35
- Joined: Thu Dec 12, 2013 7:58 am
Re: LED project
thank you sketch works i will look at it to see how it works, i had done some pre learning but all that programing had buttons addressed to their own pins where these are on one pin
i am aiming to get the clock up and running setting the time using the buttons.
at present i have spent time working on an old program, i was given but had to update all the library files as they did not have arduino.h in, and i seem to have set most of the pins where i want them and the clock although i only have 4,5,6,7 on the led, not run it on the board yet i was just using verify
i am aiming to get the clock up and running setting the time using the buttons.
at present i have spent time working on an old program, i was given but had to update all the library files as they did not have arduino.h in, and i seem to have set most of the pins where i want them and the clock although i only have 4,5,6,7 on the led, not run it on the board yet i was just using verify
-
- Posts: 35
- Joined: Thu Dec 12, 2013 7:58 am
Re: LED project
i have added your program to my RTC program, now i need to work out how to make the buttons change the time,instead of just printing and the select button to go to the pwm pin menu,
here is what i have so far
here is what i have so far
Code: Select all
// DS1302_LCD (C)2010 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// DS1302: RST pin -> Mega 2560 pin 26
// I/O pin -> pin 24
// SCK pin -> pin 22
// LCD: Keypad shield 6 button
// DB7 -> Mega 2560 pin 7
// DB6 -> Mega 2560 pin 6
// DB5 -> Mega 2560 pin 5
// DB4 -> Mega 2560 pin 4
// E -> Mega 2560 pin 9
// RS -> Mega 2560 pin 8
// Backlite -> Mega 2560 pin 10
#include <LiquidCrystal.h>
#include <DS1302.h>
DS1302 rtc(26, 24, 22); // Init the DS1302
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // Init the LCD
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
// read the buttons
int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from the sensor
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
// For V1.1 us this threshold
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 250) return btnUP;
if (adc_key_in < 450) return btnDOWN;
if (adc_key_in < 650) return btnLEFT;
if (adc_key_in < 850) return btnSELECT;
return btnNONE; // when all others fail, return this...
}
void setup()
{
rtc.halt(false); // Set the clock to run-mode, and disable the write protection
rtc.writeProtect(false);
lcd.begin(16, 2); // Setup LCD to 16x2 characters
}
void loop()
{
lcd.setCursor(6, 0); // Display time on the upper line
lcd.print(rtc.getTimeStr());
lcd.setCursor(1, 0); // Display abbreviated Day-of-Week in the upper left corner
lcd.print(rtc.getDOWStr(FORMAT_SHORT));
lcd.setCursor(5, 1); // Display date in the lower right corner
lcd.print(rtc.getDateStr());
delay (1000); // Wait one second before repeating :)
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
lcd.print(millis()/1000); // display seconds elapsed since power-up
lcd.setCursor(0,1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnRIGHT:
{
lcd.print("RIGHT ");
break;
}
case btnLEFT:
{
lcd.print("LEFT ");
break;
}
case btnUP:
{
lcd.print("UP ");
break;
}
case btnDOWN:
{
lcd.print("DOWN ");
break;
}
case btnSELECT:
{
lcd.print("SELECT");
break;
}
case btnNONE:
{
lcd.print("NONE ");
break;
}
}
}
-
- Posts: 35
- Joined: Thu Dec 12, 2013 7:58 am
Re: LED project
i have been thinking the clock can be set by the pc, and it seems to keep good time. So i think i will leave the clock as it is, and use the select button to move from clock screen to a program screen for the pwr pins to control the led
what do you think
what do you think
-
- Posts: 35
- Joined: Thu Dec 12, 2013 7:58 am
Re: LED project
morning andrew
i am still struggling with making adjustable menu for the output pins and after your reply about the RTC in the other forum i have ordered a new 1307 and 10 buttons from you as this may be better for me than trying to mod the program i have to suit what i want to do.
my next question is in the original build the guy used a Duemilanove board will my mega do the same
here is the build.
http://www.nano-reef.com/topic/321511-t ... seriously/
any advice you could give me would be greatly appreciated,
it was done on an older version so may need to still mess with the programing,
i am still struggling with making adjustable menu for the output pins and after your reply about the RTC in the other forum i have ordered a new 1307 and 10 buttons from you as this may be better for me than trying to mod the program i have to suit what i want to do.
my next question is in the original build the guy used a Duemilanove board will my mega do the same
here is the build.
http://www.nano-reef.com/topic/321511-t ... seriously/
any advice you could give me would be greatly appreciated,
it was done on an older version so may need to still mess with the programing,
Re: LED project
It does indeed look like this software is out of date and was written for a pre 1.0 version of the Arduino IDE. You could try downloading one of the older versions from the Arduino website:
http://arduino.cc/en/Main/OldSoftwareReleases
I would try V22 or 23. You can save these to your computer and run them along side your current version of the IDE and they should still work with your Mega. Try and see if the code will then compile without any errors. This is quite a complicated program for a someone that is new to this so you will be doing quite well of you get that far.
http://arduino.cc/en/Main/OldSoftwareReleases
I would try V22 or 23. You can save these to your computer and run them along side your current version of the IDE and they should still work with your Mega. Try and see if the code will then compile without any errors. This is quite a complicated program for a someone that is new to this so you will be doing quite well of you get that far.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.
-
- Posts: 35
- Joined: Thu Dec 12, 2013 7:58 am
Re: LED project
just found an updated code and he says i only need the library for the 1307 clock.
The DS1307 library is the only external library you need; the rest are included in the 1.0.5 Arduino software.
The DS1307 library is the only external library you need; the rest are included in the 1.0.5 Arduino software.
-
- Posts: 35
- Joined: Thu Dec 12, 2013 7:58 am
Re: LED project
now i have the 1307 clock working, and i have found a basic program that controls it, i have some led stuff on it but now l need to expand on what i have.
as i learn more it gets easier, changing from pre 1.0 to 1.0 and above is going well giving me modules of code and then i knit them together, i am still no where near where i want to be but have a basic program up and running.
the clock needs a bit of adjusting as i gain time but have found a sketch that re-syncs the time just need to monitor how much i am gaining. Once done i need to control the settings using the buttons and control the fade better as sunrise only takes 2 hours and fall is the same.
if anyone has any ideas please let me know.
here is the code i am testing with
as i learn more it gets easier, changing from pre 1.0 to 1.0 and above is going well giving me modules of code and then i knit them together, i am still no where near where i want to be but have a basic program up and running.
the clock needs a bit of adjusting as i gain time but have found a sketch that re-syncs the time just need to monitor how much i am gaining. Once done i need to control the settings using the buttons and control the fade better as sunrise only takes 2 hours and fall is the same.
if anyone has any ideas please let me know.
here is the code i am testing with
Code: Select all
#include <Wire.h>
#include <LiquidCrystal.h>
#define DS1307_ADDRESS 0x68
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
const int Blue1Pin = 44;
const int Green2Pin = 45;
const int Red3Pin = 46;
const int White4Pin = 47;
const int Night1Pin = 13;
const unsigned long HOUR = 60 * 60;
const unsigned long MINUTE = 60;
const int TARGET_BRIGHTNESS = (255 * 3) / 3.5;
void setup()
{
lcd.begin(16, 2);
Wire.begin();
}
byte bcdToDec(byte val) {
return ( (val/16*10) + (val%16) );
}
void loop()
{
lcd.clear();
lcd.setCursor(0,0);
Wire.beginTransmission(DS1307_ADDRESS);
Wire.write((byte)0);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 3);
int RTCSecond = bcdToDec(Wire.read());
int RTCMinute = bcdToDec(Wire.read());
int RTCHour = bcdToDec(Wire.read() & 0b111111);
if(RTCHour < 10) {
lcd.print("0");
}
lcd.print(RTCHour);
lcd.print(":");
if(RTCMinute < 10) {
lcd.print("0");
}
lcd.print(RTCMinute);
lcd.print(":");
if(RTCSecond < 10) {
lcd.print("0");
}
lcd.print(RTCSecond);
lcd.print(":");
unsigned long time = RTCHour * HOUR + RTCMinute * MINUTE + RTCSecond; // Time in seconds
analogWrite(Blue1Pin, brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE));//pin44 green
analogWrite(Green2Pin, brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE));//pin45 red
analogWrite(Red3Pin, brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+54*MINUTE));//pin46 blue
analogWrite(White4Pin, brightness(time, 2*HOUR+50*MINUTE, 22*HOUR+52*MINUTE));//pin47
analogWrite(Night1Pin, TARGET_BRIGHTNESS);
lcd.setCursor(0,1);
if(((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255) < 10) {
lcd.print("0");
}
lcd.print((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255);
lcd.print("%");
lcd.setCursor(4,1);
if(((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255) < 10) {
lcd.print("0");
}
lcd.print((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255);
lcd.print("%");
lcd.setCursor(8,1);
if(((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+54*MINUTE))*100/255) < 10) {
lcd.print("0");
}
lcd.print((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+54*MINUTE))*100/255);
lcd.print("%");
lcd.setCursor(12,1);
if(((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255) < 10) {
lcd.print("0");
}
lcd.print((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255);
lcd.print("%");
delay(1000);
}
byte brightness(unsigned long time, unsigned long fadeUpStart, unsigned long fadeDownStart)
{
if (time >= fadeUpStart + HOUR && time <= fadeDownStart)
return TARGET_BRIGHTNESS;
if (time >= fadeUpStart && time <= fadeUpStart + HOUR)
{
unsigned long seconds = time - fadeUpStart;
return TARGET_BRIGHTNESS * seconds / (HOUR);
}
if (time >= fadeDownStart && time <= fadeDownStart + HOUR)
{
unsigned long seconds = (fadeDownStart + (HOUR)) - time;
return TARGET_BRIGHTNESS * seconds / (HOUR);
}
return 0;
}
-
- Posts: 35
- Joined: Thu Dec 12, 2013 7:58 am
Re: LED project
buttons are on just need to make them change menu now.
no idea where to start.
i am thinking to make blinking courser that moves along row 2 and clear screen when i select then some how make it choose a start time and end time with a fade time
no idea where to start.
i am thinking to make blinking courser that moves along row 2 and clear screen when i select then some how make it choose a start time and end time with a fade time
Code: Select all
#include <Wire.h>
#include <LiquidCrystal.h>
#define DS1307_ADDRESS 0x68
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
// read the buttons
int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from the sensor
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
// For V1.1 us this threshold
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 250) return btnUP;
if (adc_key_in < 450) return btnDOWN;
if (adc_key_in < 650) return btnLEFT;
if (adc_key_in < 850) return btnSELECT;
// For V1.0 comment the other threshold and use the one below:
/*
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
*/
return btnNONE; // when all others fail, return this...
}
const int Blue1Pin = 44;
const int Green2Pin = 45;
const int Red3Pin = 46;
const int White4Pin = 47;
const int Night1Pin = 48;
const unsigned long HOUR = 60 * 60;
const unsigned long MINUTE = 60;
const int TARGET_BRIGHTNESS = (255 * 3) / 3.5;
void setup()
{
lcd.begin(16, 2);
Wire.begin();
lcd.print("Push"); // print a simple message
}
byte bcdToDec(byte val) {
return ( (val/16*10) + (val%16) );
}
void loop()
{
lcd.setCursor(10,0); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnRIGHT:
{
lcd.print("RIGHT ");
break;
}
case btnLEFT:
{
lcd.print("LEFT ");
break;
}
case btnUP:
{
lcd.print("UP ");
break;
}
case btnDOWN:
{
lcd.print("DOWN ");
break;
}
case btnSELECT:
{
lcd.print("SELECT");
break;
}
case btnNONE:
{
lcd.print("NONE ");
break;
}
}
//lcd.clear();
lcd.setCursor(0,0);
Wire.beginTransmission(DS1307_ADDRESS);
Wire.write((byte)0);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 3);
int RTCSecond = bcdToDec(Wire.read());
int RTCMinute = bcdToDec(Wire.read());
int RTCHour = bcdToDec(Wire.read() & 0b111111);
if(RTCHour < 10) {
lcd.print("0");
}
lcd.print(RTCHour);
lcd.print(":");
if(RTCMinute < 10) {
lcd.print("0");
}
lcd.print(RTCMinute);
lcd.print(":");
if(RTCSecond < 10) {
lcd.print("0");
}
lcd.print(RTCSecond);
lcd.print(":");
unsigned long time = RTCHour * HOUR + RTCMinute * MINUTE + RTCSecond; // Time in seconds
analogWrite(Blue1Pin, brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE));//pin44 green
analogWrite(Green2Pin, brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE));//pin45 red
analogWrite(Red3Pin, brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+54*MINUTE));//pin46 blue
analogWrite(White4Pin, brightness(time, 2*HOUR+50*MINUTE, 22*HOUR+52*MINUTE));//pin47
analogWrite(Night1Pin, TARGET_BRIGHTNESS);
lcd.setCursor(0,1);
if(((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255) < 10) {
lcd.print("0");
}
lcd.print((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255);
lcd.print("%");
lcd.setCursor(4,1);
if(((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255) < 10) {
lcd.print("0");
}
lcd.print((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255);
lcd.print("%");
lcd.setCursor(8,1);
if(((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+54*MINUTE))*100/255) < 10) {
lcd.print("0");
}
lcd.print((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+54*MINUTE))*100/255);
lcd.print("%");
lcd.setCursor(12,1);
if(((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255) < 10) {
lcd.print("0");
}
lcd.print((brightness(time, 22*HOUR+50*MINUTE, 22*HOUR+52*MINUTE))*100/255);
lcd.print("%");
delay(1000);
}
byte brightness(unsigned long time, unsigned long fadeUpStart, unsigned long fadeDownStart)
{
if (time >= fadeUpStart + MINUTE && time <= fadeDownStart)
return TARGET_BRIGHTNESS;
if (time >= fadeUpStart && time <= fadeUpStart + MINUTE)
{
unsigned long seconds = time - fadeUpStart;
return TARGET_BRIGHTNESS * seconds / (MINUTE);
}
if (time >= fadeDownStart && time <= fadeDownStart + MINUTE)
{
unsigned long seconds = (fadeDownStart + (MINUTE)) - time;
return TARGET_BRIGHTNESS * seconds / (MINUTE);
}
return 0;
}
-
- Posts: 35
- Joined: Thu Dec 12, 2013 7:58 am
Re: LED project
A stroke of luck i got the big program working on the board "i think it is working"
my problem now is still the buttons.
the program at present has
do you have any idea how to convert the new buttons to take the position of these buttons
new button code you gave me,
Here is the library for the old buttons CPP
And the buttons h
my problem now is still the buttons.
the program at present has
Code: Select all
// create the buttons
Button menu = Button(28,PULLDOWN);
Button select = Button(29,PULLDOWN);
Button plus = Button(30,PULLDOWN);
Button minus = Button(31,PULLDOWN);
new button code you gave me,
Code: Select all
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
// read the buttons
int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from the sensor
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
// For V1.1 us this threshold
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 250) return btnUP;
if (adc_key_in < 450) return btnDOWN;
if (adc_key_in < 650) return btnLEFT;
if (adc_key_in < 850) return btnSELECT;
// For V1.0 comment the other threshold and use the one below:
/*
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
*/
return btnNONE; // when all others fail, return this...
}
void setup()
{
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0);
lcd.print("Push the buttons"); // print a simple message
}
void loop()
{
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
lcd.print(millis()/1000); // display seconds elapsed since power-up
lcd.setCursor(0,1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnRIGHT:
{
lcd.print("RIGHT ");
break;
}
case btnLEFT:
{
lcd.print("LEFT ");
break;
}
case btnUP:
{
lcd.print("UP ");
break;
}
case btnDOWN:
{
lcd.print("DOWN ");
break;
}
case btnSELECT:
{
lcd.print("SELECT");
break;
}
case btnNONE:
{
lcd.print("NONE ");
break;
}
}
}
Here is the library for the old buttons CPP
Code: Select all
/*
||
|| @file Button.cpp
|| @version 1.6
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Provide an easy way of making buttons
|| #
||
|| @license
|| | Copyright (c) 2009 Alexander Brevig. All rights reserved.
|| | This code is subject to AlphaLicence.txt
|| | alphabeta.alexanderbrevig.com/AlphaLicense.txt
|| #
||
*/
//include the class definition
#include "Button.h"
/*
|| <<constructor>>
|| @parameter buttonPin sets the pin that this switch is connected to
|| @parameter buttonMode indicates PULLUP or PULLDOWN resistor
*/
Button::Button(uint8_t buttonPin, uint8_t buttonMode){
this->pin=buttonPin;
pinMode(pin,INPUT);
buttonMode==PULLDOWN ? pulldown() : pullup();
state = 0;
bitWrite(state,CURRENT,!mode);
}
/*
|| Set pin HIGH as default
*/
void Button::pullup(void){
mode=PULLUP;
digitalWrite(pin,HIGH);
}
/*
|| Set pin LOW as default
*/
void Button::pulldown(void){
mode=PULLDOWN;
//digitalWrite(pin,LOW);
}
/*
|| Return the bitWrite(state,CURRENT, of the switch
*/
bool Button::isPressed(void){
bitWrite(state,PREVIOUS,bitRead(state,CURRENT));
if (digitalRead(pin) == mode){
bitWrite(state,CURRENT,false);
} else {
bitWrite(state,CURRENT,true);
}
if (bitRead(state,CURRENT) != bitRead(state,PREVIOUS)){
bitWrite(state,CHANGED,true);
}else{
bitWrite(state,CHANGED,false);
}
return bitRead(state,CURRENT);
}
/*
|| Return true if the button has been pressed
*/
bool Button::wasPressed(void){
if (bitRead(state,CURRENT)){
return true;
} else {
return false;
}
}
/*
|| Return true if state has been changed
*/
bool Button::stateChanged(void){
return bitRead(state,CHANGED);
}
/*
|| Return true if the button is pressed, and was not pressed before
*/
bool Button::uniquePress(void){
return (isPressed() && stateChanged());
}
/*
|| @changelog
|| | 2009-05-05 - Alexander Brevig : Added uniquePress()
|| | 2009-04-24 - Alexander Brevig : Added wasPressed()
|| | 2009-04-12 - Alexander Brevig : Added constructor
|| | Shortened logic
|| | 2009-04-10 - Alexander Brevig : Namechange from Switch
|| | 2009-04-07 - Alexander Brevig : Altered API
|| | 2008-10-23 - Alexander Brevig : Initial Release
|| | 2008-10-22 - Alexander Brevig : Class implemented
|| #
*/
Code: Select all
/*
||
|| @file Button.h
|| @version 1.6
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Provide an easy way of making buttons
|| #
||
|| @license
|| | Copyright (c) 2009 Alexander Brevig. All rights reserved.
|| | This code is subject to AlphaLicence.txt
|| | alphabeta.alexanderbrevig.com/AlphaLicense.txt
|| #
||
*/
#ifndef BUTTON_H
#define BUTTON_H
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#define PULLUP HIGH
#define PULLDOWN LOW
#define CURRENT 0
#define PREVIOUS 1
#define CHANGED 2
class Button{
public:
Button(uint8_t buttonPin, uint8_t buttonMode=PULLDOWN);
void pullup();
void pulldown();
bool isPressed();
bool wasPressed();
bool stateChanged();
bool uniquePress();
private:
uint8_t pin;
uint8_t mode;
uint8_t state;
};
#endif
/*
|| @changelog
|| | 1.6 2009-05-05 - Alexander Brevig : Added uniquePress, it returns true if the state has changed AND the button is pressed
|| | 1.5 2009-04-24 - Alexander Brevig : Added stateChanged, @contribution http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=viewprofile;username=klickadiklick
|| | 1.4 2009-04-24 - Alexander Brevig : Added wasPressed, @contribution http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=viewprofile;username=klickadiklick
|| | 1.3 2009-04-12 - Alexander Brevig : Added constructor with one parameter Button(uint8_t buttonPin)
|| | 1.2 2009-04-10 - Alexander Brevig : Namechange from Switch to Button
|| | 1.1 2009-04-07 - Alexander Brevig : Altered API
|| | 1.0 2008-10-23 - Alexander Brevig : Initial Release
|| #
*/