Author Topic: Code for 4 Mode Switch  (Read 5852 times)

Offline SYSTEM aka (Cyberpyrot)

  • Site Founder
  • Acidmods Alumni
  • Around the block
  • *
  • Posts: 4091
  • Post quality +3/-0
  • Gender: Male
Code for 4 Mode Switch
« on: March 22, 2008, 04:54:44 PM »
Code is in pic Basic Pro it is a rough code and will get better with time we just want to show you we are working.. With this chip you can use the note button to control all sorts of led combonations.. Lord Nico also has the code in assembly and will be posting a POC soon. Lord Nico's Poc will be inside a psp



Keep in mind we are planning to get these boards made super tiny with SMD componants this is just my proto typing board for coding..

the modes are as follow

Mode 1:
hold button down for 5 seconds turns led one on.

Mode 2:
Hold button down for 5 seconds turns led one off and turns led 2 on.

Mode 3:
Hold button down for 5 seconds turns led one on and turns led 3 on.

Mode 4:
Turns all leds off.

Quote
x VAR BYTE
y VAR BYTE
i VAR BYTE
TRISB = 0 'Set PortB to outputs.

 
x = 0: y = 0:i = 0

start:

IF PORTA.1 = 0 Then Pause 500
IF PORTA.1 = 0 Then mode
GoTo start

mode:
i = i + 1
IF i = 5 Then i = 1 ' reset to 1

GoSub blink

IF i = 1 Then 'Light White LED
PORTB.0 = 0: PORTB.1 = 1: PORTB.2 = 0
EndIF

IF i = 2 Then 'Light Green LED
PORTB.0 = 1: PORTB.1 = 0: PORTB.2 = 0
EndIF

IF i = 3 Then 'Light Red and White LED
PORTB.0 = 0: PORTB.1 = 1: PORTB.2 = 1
EndIF

IF i = 4 Then 'All Leds off
PORTB.0 = 0: PORTB.1 = 0: PORTB.2 = 0
EndIF


GoTo start

blink:
PORTB.2 = 0
For y = 1 TO i
Toggle PORTB.2
Pause 500
Toggle PORTB.2
Pause 500
Next
Return
« Last Edit: March 24, 2008, 06:52:44 PM by Cyberpyrot »

Offline zbblanton

  • Acid Modder
  • *
  • Posts: 979
  • Post quality +5/-0
  • Gender: Male
    • My modding site
Re: Code for 4 Mode Switch
« Reply #1 on: March 22, 2008, 10:03:22 PM »
is basic pro the some as basic?

Offline P3nnyw1se

  • Acid Modder
  • *
  • Posts: 862
  • Post quality +1/-0
  • Gender: Male
  • AcidMaG
    • Myspace
Re: Code for 4 Mode Switch
« Reply #2 on: March 22, 2008, 10:20:23 PM »
looks good


Offline tibor28

  • Who Farted ???
  • *
  • Posts: 222
  • Post quality +0/-0
Re: Code for 4 Mode Switch
« Reply #3 on: March 25, 2008, 04:12:49 AM »
looks cool, just got a noobish question, how do you actually get your source code programmed into the chip? do you somehow connect it to pc or what? :confused:

Offline SYSTEM aka (Cyberpyrot)

  • Site Founder
  • Acidmods Alumni
  • Around the block
  • *
  • Posts: 4091
  • Post quality +3/-0
  • Gender: Male
Re: Code for 4 Mode Switch
« Reply #4 on: March 25, 2008, 04:30:59 AM »
looks cool, just got a noobish question, how do you actually get your source code programmed into the chip? do you somehow connect it to pc or what? :confused:

yes you need a microcontroller programmer.

Offline everlasting_will

  • ♪♪♪ Tone deff ♪♪♪
  • *
  • Posts: 74
  • Post quality +0/-0
  • Gender: Male
    • BEPSP
Re: Code for 4 Mode Switch
« Reply #5 on: April 18, 2008, 07:49:13 AM »
Man! That is all the code? Well i don't know anything about basic pro but it seems quite simple, quite intuitive. Is that all the necessary code for using the pic as four switches, is that the only thing needed to be written into the PIC?
I had a look at Lord Nico's assembly code and pffff, not very easy. Well in any case i will try to program the PIC's on "C" language. The thing that afraid me the most is the coding lines like for example when programming the PSP you have to say if you are in user mode or in kernel mode, like you have to enter some protocol lines in order that the program will work properly. It seemed like Lord Nico had some configuration lines but your program haven't. Well i don't even know if you are using the same PIC so i don't know if that big difference is just because of the assembly or also due to some differences on the PIC's.
Man i just can't wait to have my programmer.
First Be then PSP !!


Offline SYSTEM aka (Cyberpyrot)

  • Site Founder
  • Acidmods Alumni
  • Around the block
  • *
  • Posts: 4091
  • Post quality +3/-0
  • Gender: Male
Re: Code for 4 Mode Switch
« Reply #6 on: April 27, 2008, 04:57:22 PM »
Man! That is all the code? Well i don't know anything about basic pro but it seems quite simple, quite intuitive. Is that all the necessary code for using the pic as four switches, is that the only thing needed to be written into the PIC?
I had a look at Lord Nico's assembly code and pffff, not very easy. Well in any case i will try to program the PIC's on "C" language. The thing that afraid me the most is the coding lines like for example when programming the PSP you have to say if you are in user mode or in kernel mode, like you have to enter some protocol lines in order that the program will work properly. It seemed like Lord Nico had some configuration lines but your program haven't. Well i don't even know if you are using the same PIC so i don't know if that big difference is just because of the assembly or also due to some differences on the PIC's.
Man i just can't wait to have my programmer.

LOL pic basic pro converts that to Hex..

 

SMF spam blocked by CleanTalk
SimplePortal 2.3.5 © 2008-2012, SimplePortal