Advertisement
edofhell

Osmose Timer V0.2B1

Sep 15th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. // Const int setup
  2. const int buttonPin = 2; // the number of the pushbutton pin
  3. const int Magnet = 10; // the number of the Magnet pin
  4. const int Ledstrip = 9; // the number of the Ledstrip pin
  5.  
  6.  
  7. // Time setup
  8. const long oneSecond = 1000; // a second is a thousand milliseconds
  9. const long oneMinute = oneSecond * 60;
  10. const long thirtyMinutes = oneMinute * 30;
  11. const long oneHour = oneMinute * 60;
  12. const long oneDay = oneHour * 24;
  13.  
  14.  
  15. int buttonState = 0; // variable for reading the pushbutton status
  16.  
  17.  
  18. void setup() {
  19.  
  20. // initialize the LED pin as an output:
  21. pinMode(Magnet, OUTPUT);
  22.  
  23. // initialize the pushbutton pin as an input:
  24. pinMode(buttonPin, INPUT);
  25.  
  26. // initialize the Ledstrip pin as an input:
  27. pinMode(Ledstrip, INPUT);
  28. }
  29.  
  30.  
  31. void loop(){
  32. // read the state of the pushbutton value:
  33. buttonState = digitalRead(buttonPin);
  34.  
  35. // check if the pushbutton is pressed.
  36. // if it is, the buttonState is HIGH:
  37. if (buttonState == HIGH) {
  38.  
  39. // turn Ledstrip on:
  40. digitalWrite(Ledstrip, HIGH);
  41.  
  42. // turn magnet on:
  43. digitalWrite(Magnet, HIGH);
  44.  
  45. // run for 30 min
  46. delay(thirtyMinutes);
  47. }
  48.  
  49.  
  50. else {
  51.  
  52.  
  53. // turn Magnet off:
  54. digitalWrite(Magnet, LOW);
  55.  
  56. // turn Ledstrip off:
  57. digitalWrite(Ledstrip, LOW);
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement