Push-Button countdown? - Raspberry Pi Forums
hello, have purchased raspberry pi 2 model b project, goal create simple heads display on 1.5" lcd (160 x 240 resolution) counter tracks how many times button pushed, want create counter start @ 120, , subtract 1 every push of button, , have second button both resets first counter , subtracts 1 second counter track how many remaining magazines have remaining.
counter decreases 1 every time first button pressed , resets when second button pressed. , second counter decreases 1 , resets @ 0 when second button pressed, meaning second button resets first counter, , decreases second counter one.
(in 24hour format) time : 1330
(remaining in magazine) ammo : 120
(number of magazines remaining) remaining : 10
(my core temperature) core temp. : 98.2f
(temperature inside pi housing) pi temp : 72f
have no idea start code or language use, again raspberry pi 2 model b noobs operating system, if give few examples or me find right language code in appreciated, hope have 1 or 2 temperature sensors (using enocean pi wireless sensor kit) , real time clock on display important part counter.
point of little project have ammunition counter display airsoft, me keep track of how ammunition have left, keep track of game time, keep track of both core temperature, , temperature of raspberry pi (some matches played outdoors in temperatures above 80 degrees fahrenheit , want avoid overheating myself of raspberry pi)
time goes , learn more make displayed values change colors decrease or increase eg;
when ammo value between 70 , 120 green, between 30 , 69 yellow, , below 29 red
when magazine value between 7 , 10 green, between 3 , 6 yellow, , below 2 red
when core temp between 82f , 90f red, between 90f , 95f yellow, between 96f , 98.9f green , above 99f red
, when pi temp @ or below 72f green, between 73f , 80f yellow, @ or above 81f red
color changes feature make display nicer , not important core function of counter
counter decreases 1 every time first button pressed , resets when second button pressed. , second counter decreases 1 , resets @ 0 when second button pressed, meaning second button resets first counter, , decreases second counter one.
(in 24hour format) time : 1330
(remaining in magazine) ammo : 120
(number of magazines remaining) remaining : 10
(my core temperature) core temp. : 98.2f
(temperature inside pi housing) pi temp : 72f
have no idea start code or language use, again raspberry pi 2 model b noobs operating system, if give few examples or me find right language code in appreciated, hope have 1 or 2 temperature sensors (using enocean pi wireless sensor kit) , real time clock on display important part counter.
point of little project have ammunition counter display airsoft, me keep track of how ammunition have left, keep track of game time, keep track of both core temperature, , temperature of raspberry pi (some matches played outdoors in temperatures above 80 degrees fahrenheit , want avoid overheating myself of raspberry pi)
time goes , learn more make displayed values change colors decrease or increase eg;
when ammo value between 70 , 120 green, between 30 , 69 yellow, , below 29 red
when magazine value between 7 , 10 green, between 3 , 6 yellow, , below 2 red
when core temp between 82f , 90f red, between 90f , 95f yellow, between 96f , 98.9f green , above 99f red
, when pi temp @ or below 72f green, between 73f , 80f yellow, @ or above 81f red
color changes feature make display nicer , not important core function of counter
try python
here's started. buttons wired between pins 26 & 24 , gnd (pin 25)
here's started. buttons wired between pins 26 & 24 , gnd (pin 25)
code: select all
import rpi.gpio gpio import time sw_in = 26 #pin 26 reset = 24 #pin 24 gpio.setmode(gpio.board) gpio.setup(sw_in,gpio.in,pull_up_down=gpio.pud_up) gpio.setup(reset,gpio.in,pull_up_down=gpio.pud_up) gpio.add_event_detect(sw_in,gpio.falling) gpio.add_event_detect(reset,gpio.falling) count1 = 120 count2 = 120 while true: if gpio.event_detected(sw_in): count1 = count1 - 1 if count1 < 1: count1 = 0 print count1,count2 time.sleep(1) # debounce if gpio.event_detected(reset): count1 = 120 count2 = count2 - 1 if count2 < 1: count2 = 120 print count1,count2 time.sleep(1) # debounce
raspberrypi
Comments
Post a Comment