Thanks for your reply.
The display is a 4 digit 7 segment display with common cathode.
The display is connected without any other chip attached. (the connectors of the display are connected to the GPIO pins)
Can you give me an example of code that reads a chunk of file into memory then use it please? (I am a bit new to python.)
Basically this is what i need to do :
use this code that is a gear indicator. It starts activating the decimal point. Then when you pressa button it shows 1 then you press again it shows 2...and so on. ***this has to run all the time***
Code: Select all
import RPi.GPIO as GPIO
import time
import os
GPIO.setmode (GPIO.BOARD)
GPIO.setwarnings(False)
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
segments = (12, 16, 18, 22, 32, 35, 33, 40)
for segment in segments:
GPIO.setup(segment, GPIO.OUT)
GPIO.output(segment, 0)
digits = (36, 37, 38, 31)
for digit in digits:
GPIO.setup(digit, GPIO.OUT)
GPIO.output(digit, 1)
gears = {'z' :[33, 40, 22, 16, 12, 35],
'zz':[32],
1 :[22, 40],
10:[12, 16, 18, 35, 33, 32],
2 :[33, 40, 32, 12, 16],
20:[35, 22],
3 :[33, 40, 32, 22, 16],
30:[12, 35],
4 :[35, 32, 40, 22],
40:[33, 16, 12],
5 :[33, 35, 32, 22, 16],
50:[40, 12],
6 :[33, 35, 32, 12, 22, 16],
60:[40],
7 :[33, 40, 22],
70:[35, 32, 12, 16],
8 :[33, 40, 32, 22, 16, 12, 35],
80:[],
9 :[32, 35, 33, 40, 22, 16],
90:[12]}
i=0
x=0
while(True):
GPIO.output(36,1)
GPIO.output(36,0)
while (GPIO.input(11)==0 and i<1):
GPIO.output(18,1)
if (GPIO.input(11)==1):
i+=1
x+=10
if i==7:
i=6
x=60
else:
GPIO.output(gears[i],1)
GPIO.output(gears[x],0)
time.sleep(.2)
if (GPIO.input(13)==1):
i-=1
x-=10
if i==0:
i=1
x=10
GPIO.output(gears[i],1)
GPIO.output(gears[x],0)
time.sleep(.2)
Then i need to read a value from a file (that shows temperature) and display it on the already connected and in use 7 segment display with common cathode (without any i2c module, just connected to the GPIO pins directly)
this si the algorithm i thought of:
read file > write content to memory > wait 5 seconds and repeat
read what you have in memory > use it do light up the corresponding segments
But all of this has to run at the same time (the temperature display to be updated every 5 seconds and the numbers to change whenever I press a button)
I am new at this so bare with me
Thank you for every suggestion.