opticalworm
New Member
I’m having trouble simulation my program.
The purpose of the program is to test my new RGB LED.
**broken link removed**
it meant to flick through 8different combination that the LED can produce with Red Green and blue. That all it sound simple but its not.
I’m setting TRISIO = ob00101000 however when I put it through MPLAB simulation is doesn’t do that. And above that The GPIO aren't changing output.
This make me very
Here are my codes.
The purpose of the program is to test my new RGB LED.
**broken link removed**
it meant to flick through 8different combination that the LED can produce with Red Green and blue. That all it sound simple but its not.
I’m setting TRISIO = ob00101000 however when I put it through MPLAB simulation is doesn’t do that. And above that The GPIO aren't changing output.
This make me very
Here are my codes.
#define LED GPIO0
#define BLUE GPIO1
#define GREEN GPIO2
#define RED GPIO4
#define BUTTON GPIO3
#include<htc.h>
unsigned char HOLD =0;
unsigned char NEXT =0;
void main()
{
TRISIO = 0b00101000;
LED = 0;
BLUE = 1;
GREEN = 1;
RED = 1;
NEXT = 0;
while(1) /*LEDS starts off*/
{
if(BUTTON == 1)
{
if(HOLD ==0)
{
NEXT++;
HOLD = 1;
}
}
else
{
HOLD = 0;
}
if(NEXT == 0) /* B-OFF G-OFF R-ON */
{
LED = 0;
BLUE = 0;
GREEN = 0;
RED = 0;
}
if(NEXT == 1) /* B-OFF G-OFF R-ON */
{
LED = 1;
RED = 0;
RED = 1;
LED = 0;
}
if(NEXT == 2)/* B-OFF G-ON R-OFF */
{
LED = 1;
GREEN =0;
GREEN = 1;
LED = 0;
}
if(NEXT == 3)/* B-OFF G-ON R-ON */
{
LED = 1;
GREEN =0;
GREEN = 1;
RED = 0;
RED = 1;
LED = 0;
}
if(NEXT == 4)/* B-ON G-OFF R-OFF */
{
LED = 1;
BLUE = 0;
BLUE = 1;
LED = 0;
}
if(NEXT == 5)/* B-ON G-OFF R-ON */
{
LED = 1;
BLUE = 0;
BLUE = 1;
RED = 0;
RED = 1;
LED = 0;
}
if(NEXT == 6)/* B-ON G-ON R-OFF */
{
LED = 1;
BLUE = 0;
BLUE = 1;
GREEN =0;
GREEN = 1;
LED = 0;
}
if(NEXT == 7)/* B-ON G-ON R-ON */
{
LED = 1;
BLUE = 0;
BLUE = 1;
GREEN = 0;
GREEN = 1;
RED = 0;
RED = 1;
LED = 0;
}
if (NEXT == 8) /* B-OFF G-OFF R-OFF */
{
NEXT = 0;
}
}
}