Return to basic – GPIO

REPOSTED

 

So to complement getting the GPIO* working on python,  I had previously set up return to basic to handle the GPIO on the pi,  I have now, with help got return to basic (rtb) working with the ladder board .

If you get the wiringPI software you (use git) then you set up the GPIO so that it can work from basic and other languages.   (see python blog entry for details on getting the software needed for python).

the program simply prints hello on the screen, until button 1 is pressed,  (far left) and exits when button 2 is pressed.   So not much at present,  However most of the program is setting stuff up,  (useful for other programs).  You Need lines 100 to 350,  lines 360 to 410 are my own addition.

 

100 // ladder set up
110 FOR i = 0 TO 9 CYCLE
120   PinMode (i, 1) // Output
130   DigitalWrite (i, 0) // Off
140 REPEAT
150 FOR i = 10 TO 13 CYCLE
160   PinMode (i, 0) // Input
170   PullUpDn (i, 2) // Activate internal pull-up
180 REPEAT
190 // Make some globals
200 //
210 ledRed1 = 0
220 ledRed2 = 1
230 ledYellow1 = 2
240 ledYellow2 = 3
250 ledGreen1 = 4
260 ledGreen2 = 5
270 ledBlue1 = 6
280 ledBlue2 = 7
290 gMan = 8
300 rMan = 9
310 //
320 buttonA = 11
330 buttonB = 10
340 buttonC = 12
350 buttonD = 13
360 // program start
370 CYCLE
380   IF DigitalRead (buttonA) = 1 THEN PRINT “hello”
390   IF DigitalRead (buttonA) = 0 THEN PRINT “bye”
395   IF DigitalRead (buttonB) = 0 THEN STOP
400 REPEAT
410 END

 

Notes

To control leds

Digitalwrite (ledBlue2,1) – led on

Digitalwrite (ledBlue2,0) – led off

* GPIO means General Purpose input / output.

 

to add to this

DigitalWrite (ledBlue2, 1)
DigitalWrite (ledBlue1, 1)
DigitalWrite (ledGreen2, 1)
DigitalWrite (ledGreen1, 1)
DigitalWrite (ledYellow2, 1)
DigitalWrite (ledYellow1, 1)
DigitalWrite (ledRed2, 1)
DigitalWrite (ledRed1, 1)