Author Topic: Another problem with c code for pic  (Read 1646 times)

0 Members and 1 Guest are viewing this topic.

Offline little_carlosTopic starter

  • Regular Contributor
  • *
  • Posts: 134
Another problem with c code for pic
« on: February 17, 2016, 01:35:24 am »
hello guys, so last time i asked how to make a counter, i solved the bouncing problem, but now i cant make it to decrease the count on the output, how can i do it? here's the code i wrote
int i;
bit o1;
bit o2;
void main() {
//////////////////////////////////////////////////////////////////////////////
trisa = 1;
porta = 0;
trisb = 0;
portb = 0;
o1 = 0;
o2 = 0;
i = 0;
//////////////////////////////////////////////////////////////////////////////
while(1){
if (Button(&PORTA,0,1,1)){
o1 = 1;
}
if(o1 && Button(&PORTA,0,1,0)){
i ++;
o1 = 0;
}
if(Button(&PORTA,1,1,1)){
o2 = 1;
}
if(o2 && Button(&PORTA,1,1,0)){
i --;
o2 = 0;
}
switch(i++){
case 1 : rb0_bit = 1; break;
case 2 : rb1_bit = 1; break;
case 3 : rb2_bit = 1; break;
}
switch(i--){
case 1 : rb0_bit = 1; break;
case 2 : rb1_bit = 1; break;
case 3 : rb2_bit = 1; break;
}
}
}
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5525
  • Country: gb
Re: Another problem with c code for pic
« Reply #1 on: February 17, 2016, 12:03:44 pm »
Two things...

What is the implementation if the Button() function?

Try using code tags to maintain indentation and readability!



Code: [Select]
#include <stdio.h>

int main(void)
{
    printf("Hello World!\n");
    return 0;
}
« Last Edit: February 17, 2016, 12:05:41 pm by Howardlong »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->