Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- const int rs = 8, en = 9, d4 =4, d5 = 5, d6 = 6, d7 = 7;
- LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
- int verifyButton (int);
- int minutes=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(minutes);
- lcd.setCursor(0, 1);
- lcd.print("minutes");
- pinMode (2, OUTPUT);
- digitalWrite (2, HIGH);
- }
- void loop() {
- int value = analogRead (A0);
- int result = verifyButton(value);
- lcd.setCursor (0,0);
- switch (result){
- case 2:{
- minutes++;
- delay (300);
- break;
- }
- case 3:{
- minutes--;
- delay (300);
- break;
- }
- }
- lcd.print(minutes);
- lcd.print(" ");
- if (value==0)
- {
- lcd.clear();
- delay (500);
- digitalWrite (2, LOW);
- while (1){
- for (int i=minutes*60; i>=0; i--){
- lcd.setCursor(0,0);
- lcd.print(i);
- lcd.print(" ");
- delay (1000);
- }
- lcd.setCursor(0,0);
- lcd.clear();
- digitalWrite(2, HIGH);
- lcd.print("Exposure finished");
- while (1){
- lcd.setCursor(0,1);
- lcd.print("");
- }
- }
- }
- }
- int verifyButton (int val){
- if (val<10) return 1;
- if (val<150) return 2;
- if (val<350) return 3;
- if (val<500) return 4;
- if (val<750)return 5;
- else return -2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement