Help.. Simple LED Project

Thread Starter

nikkzzz05

Joined Oct 19, 2012
4
good day, we need a simple program for pic16f84a, the requiurements are, there should be at 2 input and output. The input are coming from the tact switch. If the tact switch is press, the LED's should lit up, and if the second switch is press the delay of the LED sequence should speed up. We are using Pic Basic plus for the software. The problem is, our prof did not teach us to code for pic16f84a, he just teach us to do the pic16f84a programmer and the developer. It's just a simple program for you guys, but for us, who do not have knowledge in it, it so difficult. I hope you could help us. Thank you in advance..
 

spinnaker

Joined Oct 29, 2009
7,830
Sounds like someone wants us to do their homework assignment.

If you know how to program the pic16f84a then you should know how to program just about any PIC for a simple program like that.

Check your datasheet. Compare the one chip to the other.

Start small like simply turning on an LED. Then add the code for the tact switch.

BTW You said: "our prof did not teach us to code for pic16f84a, he just teach us to do the pic16f84a"

So he did teach you to program the chip that you have.
 

spinnaker

Joined Oct 29, 2009
7,830
And after you have check your datasheet and tried to code something, if you are still stuck, then and only then ask more questions.
 

Thread Starter

nikkzzz05

Joined Oct 19, 2012
4
he just teach us to do the programmer, the hardware that load the program into the pic, and the developer to test the program.he did not teach us the syntax use in PicBasic and how to code it.ok, Ill try my best to code...thank you for your response
 
Last edited:

Thread Starter

nikkzzz05

Joined Oct 19, 2012
4
i forget to include, we have a sample program that has 2 inputs, given by our prof. 1 for the speed of sequence of the LED, and 1 for the, i think if press the LED will lit up. The problem here, is when we test it in the developer, nothing happens. so what our prof did is, he revise the code, he erase the code for the switches and speed, and after testing it, it worked. I think there is a problem in the code for the switch. The compiler use in this program is PicBasic Plus. here is the code with switches.

Rich (BB code):
'OPTIMISER_LEVEL = 6                                      'SET FOR MAXIMUM OPTIMISER LEVEL
     Device = 16F84A
              XTAL = 4
              TRISB = %00000000                           'SET PORT B TO ALL OUTPUT
              TRISA = %00000011                            'I THINK THIS IS TO SET 2 PORTS FROM PORT A TO INPUT
      Symbol Button1 PORTA.0                              'push button
       Symbol speed PORTA.1                                'push button
     Dim sw as Byte
     Dim sp as word
             sw = 1
             sp = 200
             PORTB = 0
      Delayms 50

Main: 
     if Button1 = 0 then
          sw = sw + 1
          delayms 50
     end if
     if speed = 0 then
          sp = sp - 25
                if sp = 0 then
                      sp = 200
       end if

    if sw = 1 then
          PORTB = %00000011
          Delayms sp
          PORTB = %11000011
          Delayms sp
          PORTB = %11001111
          Delayms sp
           PORTB = %11111111
          Delayms sp
          PORTB = %00000000
          Delayms sp
       Goto main
end
the only part. that i understand is the if sw = 1 then the codes. can you pls help me to debug this program? thank you very much
 
Last edited by a moderator:

spinnaker

Joined Oct 29, 2009
7,830
Please use capital letter at the start of you sentences. It makes it easier to read.

the only part. that i understand is the if sw = 1 then the codes. can you pls help me to debug this program? thank you very much
Someone wasn't listening in class. :)

Are you certain everything is hooked up correctly? Where is your schematic?

As I said in a previous post start simple. I am not familiar with Pic Basic so there may be errors but this should get you started.

Rich (BB code):
'OPTIMISER_LEVEL = 6                                      'SET FOR MAXIMUM OPTIMISER LEVEL
     Device = 16F84A
              XTAL = 4
              TRISB = %00000000                           'SET PORT B TO ALL OUTPUT 


Main:
    DelayMs 100
    PortB = 255   'You might want to use LatchB here see if that works
    DelayMs 100
    PortB = 0   'You might want to use LatchB here see if that works
    Goto Main
If I coded this correctly, it should flash all of the LEDs on PortB on and off every 100 ms.
 
Top