BrainPad Pulse and MicroPython

New tests !

Code:

import BrainPad

def setup():
    global buttonA
    global buttonB
    global display
    global led
    
    display=BrainPad.Display
    display.Clear()
    display.Show()
    display.Print("Hello GHI !")
    display.Print("")
    display.Print("Push a Button")

    led=BrainPad.Digital("led")
    buttonA=BrainPad.Button("A",0)
    buttonB=BrainPad.Button("B",0)
 
def loop():
    global led
    global buttonA
    global buttonB
    global display
    
    if(BrainPad.In(buttonA)):
       display.Print("A Button pressed")
       BrainPad.Out(led,1)
       
    if(BrainPad.In(buttonB)):
       display.Print("B Button pressed")
       BrainPad.Out(led,0)
       
    BrainPad.Wait(0.02)
     
setup()

while True:
    loop()
3 Likes

You can try:

from BrainPad import *

Clear()
Show()
Print("Hello GHI !")

led = Digital("led")
Out(led,1)
btA = Button("A",0)

......

they also work.

2 Likes

They work too but I like to know from which library functions come. :wink:

2 Likes

Yes, it’s Pytonic. :slight_smile:

2 Likes

Hello GHI,
hello

Here is the “Hello World” for my 10th graders.

from BrainPad import *
led=Digital("P0")
Clear()
Print("Hello GHI !")

while (True):
    Out(led,1)
    Wait(0.5)
    Out(led,0)
    Wait(0.5)

I would like to make the 12th graders version as below but I don’t know the P0 pin value.

from machine import Pin
import time
 
Led = Pin(???, Pin.OUT)
 
while(True):
    Led.on()
    time.sleep(0.5)
    Led.off()
    time.sleep(0.5)

Can we have the pin matching or Pulse diagram ? Thank’s.

2 Likes

Not sure what you mean. Isn’t it P1?

With machine package, microPython want a pin number.
Example :
On ESP32 Feather Huzzah : Led = Pin(13, Pin.OUT)
On Raspberry Pi Pico : Led = Pin(25, Pin.OUT)

But those numbers only make sense if you are looking at the schematic.

Yes. My studends learn to read schematics. Can we have Pulse schematic ?

1 Like

We haven’t made a decision on sharing the schematics

Ok. I await your decision for the schematic.
Otherwise my multimeter gave the answer: pin 15 for the above assembly so the code is :

from  BrainPad import *
import time
 
Led=Pin("PA5",Pin.OUT)
 
while(True):
    Led.on()
    time.sleep(0.5)
    Led.off()
    time.sleep(0.5)
1 Like

You must have very good eyes.

or a good magnifying glass :rofl:

2 Likes

Looks like you have older code. This should be led=Digital(P0) or we have an error

1 Like

I will test tomorrow without quotes.

led=Digital(“P0”) and led=Digital(P0) work with SITCore-SC13-MP-Firmware-v0.2.2.glb

2 Likes