Let's Make Robots!

Having problem with basic code :(

Basic code bellow (PROBLEM): As soon as it writes to the chip it all comes on, and then starts flashing o.0 even though b1 = 0



high b.1
high b.2
high b.3
high b.4
high b.5
high b.6
high b.7
high c.0
high c.1
high c.2
high c.3
b1 = 0
main:       serrxd b1
        if b1 = 1 then low b.1 pause 50 high b.1 goto main endif
        if b1 = 2 then low b.2 pause 50 high b.2 goto main endif
        if b1 = 3 then low b.3 pause 50 high b.3 goto main endif
        if b1 = 4 then low b.4 pause 50 high b.4 goto main endif
        if b1 = 5 then low b.5 pause 50 high b.5 goto main endif
        if b1 = 6 then low b.6 pause 50 high b.6 goto main endif
        if b1 = 7 then low b.7 pause 50 high b.7 goto main endif
        if b1 = 8 then low c.0 pause 50 high c.0 goto main endif
        if b1 = 9 then low c.1 pause 50 high c.1 goto main endif
        if b1 = 10 then low c.2 pause 50 high c.2 goto main endif
        if b1 = 11 then low c.3 pause 50 high c.3 goto main endif
goto main
'reduce download time


Can anyone solve this for me? i really need this issue sorted asap :(

I really think it's something to do with the C pins because as soon as i take them out it works fine so how do i change the pins to outputs only?

I changed all the cpins to 11111111 and b pins to 11111111

but the lights leds aint in c pins, only b pins have 7 lights but now when i wait they start flashing, and it gets faster n faster over time?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

To test if the picaxe is resetting or running the program. pause the program with every led in the initialisation like this:

high b.1

pause 200

high b.2

pause 200

high b.3

pause 200


If the picaxe is indeed resetting, the lights will not be flashing but you should see the lights coming on one by one instead of all at the same time.

I think your problem is electrical and not in the program. Perhaps you draw too much current from the chip and it is resetting for some reason. If you connect 12 LEDs with a 330Ohm resistor directly on the output pins running at 5V: you will draw more than the 90mA the chip can deliver when all the LEDs are turned on (20mA per output but max=90mA total)

Show us how the lights are connected. Can you post a picture?

Does it work with less LEDs? for example 2 port C pins and 2 port B pins?

Does it work if you start with all lights off and lighting them one by one depending on the value of b1?


Thanks guys, it may be a chip problem though, so i've switched over to the 40x2 and i've downloaded the data to it, going to test it now, maybe my 28x2 chip is faulty... if it is i'll deal with it, probably reburn the firmware or something


let b1 = 0

i think that's it

dirC is the variable your looking for.

let dirsC = %00001111      to make C.0 - C.3 outputs

let pinsC = %00001111    switch them on in one statement

let pinsB = %11111111  switch on all 8 pins on port B

But your code allready makes the pins outputs: high C.0 - high C.3 should make those pins output. The code runs OK as it is in the simulator and I see nothing wrong with it. 

Explain please what starts flashing: all the lights or just one or only the ones on port C?