Hello, I'm quite new into PIC and still learning as I do it.
For starter, I'm trying to copy this guy project "https://www.instructables.com/Mood-vase/"
This is the error it does. I tried googling it for hours, but still cannot find my answer.
For starter, I'm trying to copy this guy project "https://www.instructables.com/Mood-vase/"
/* Main.c file generated by New Project wizard
*
* Created: Wed Dec 8 2021
* Processor: PIC12F683
* Compiler: MPLAB XC8
*/
#include <pic.h>
__CONFIG(0x30C4);
/* __________
| \__/ |
Vdd | | Vss
BLUE <| GP5 GP0 |> GREEN
BATT >| GP4 GP1 |> RED
| GP3 GP2 |< LIGHT
|__________|
*/
#define LED1 GPIO5
#define LED2 GPIO0
#define LED3 GPIO1
#define THRESH 254
unsigned char duty1, duty2, duty3;
bit dir1, dir2, dir3;
bit set1, set2, set3;
unsigned char delay1, delay2, delay3;
bit sun, batt, off;
unsigned char pulsecount;
unsigned char seed;
unsigned char softscale;
unsigned char rand(void);
void suncheck(void);
void main() {
// *** config ***
// Oscillator
OSCCON = 0b01110110; // 8MHz clock
// WDT
WDTCON = 0b00010110; // wdt set to max prescale
// Port settings
GPIO = 0b00100011; // port settings
TRISIO = 0b11011100;
// Comparators
CMCON0 = 0b00000111; // Comparators off
// ADC
ANSEL = 0b01011100; // A/D on chanels 2 and 3
ADCON0 = 0b00001001; // start with AN2
// Interrupts
INTCON = 0b11100000; // ADC interrupt
// Timers
OPTION = 0b11000101;
pulsecount = 0;
while(1) {
// *** software PWM ***
if(set1 == 0) {
if(TMR0 >= duty1) {
LED1 = 1;
set1 = 1;
}
}
if(set2 == 0) {
if(TMR0 >= duty2) {
LED2 = 1;
set2 = 1;
}
}
if(set3 == 0) {
if(TMR0 >= duty3) {
LED3 = 1;
set3 = 1;
}
}
}
}
void interrupt isr(void) {
if(T0IF) {
// *** software PWM ***
set1 = 0;
set2 = 0;
set3 = 0;
if(delay1 == 0) {
LED1 = 0;
if(dir1 == 0) {
duty1++;
if(duty1 == 255) {
dir1 = 1;
}
}
else {
duty1--;
if(duty1 == 0) {
dir1 = 0;
delay1 = rand();
suncheck();
}
}
}
else {
if(softscale == 0) {
delay1--;
}
}
if(delay2 == 0) {
LED2 = 0;
if(dir2 == 0) {
duty2++;
if(duty2 == 255) {
dir2 = 1;
}
}
else {
duty2--;
if(duty2 == 0) {
dir2 = 0;
delay2 = rand();
}
}
}
else {
if(softscale == 0) {
delay2--;
}
}
if(delay3 == 0) {
LED3 = 0;
if(dir3 == 0) {
duty3++;
if(duty3 == 255) {
dir3 = 1;
}
}
else {
duty3--;
if(duty3 == 0) {
dir3 = 0;
delay3 = rand();
}
}
}
else {
if(softscale == 0) {
delay3--;
}
}
softscale ++;
if(softscale > 15) {
softscale = 0;
}
T0IF = 0;
}
}
unsigned char rand (void) {
seed = 97 * seed + 133;
return seed;
}
void suncheck(void) {
// *** check for sunlight ***
if(delay1 > 0 && delay2 > 0) {
GODONE = 1;
while(GODONE == 1);
if(ADRESH > THRESH) {
sun = 0;
pulsecount++;
}
else {
sun = 1;
pulsecount = 0;
}
ADCON0 = 0b00001101; // AN3 (BATT)
GODONE = 1;
while(GODONE == 1);
if(ADRESH > 51) {
batt = 0;
}
else {
batt = 1;
}
if(pulsecount > 250) {
off = 1;
}
while(sun == 1 || batt == 0 || off == 1) {
LED1 = 1;
LED3 = 1;
if(batt == 1) {
LED2 = 1;
}
else {
LED2 ^= 1;
}
ADCON0 = 0b00001001; // AN2 (LIGHT)
GIE = 0;
OPTION = 0b11111101; // WDT prescale 1:32
SWDTEN = 1;
SLEEP();
// returning from sleep
GIE = 1;
OPTION = 0b11000101; // Reset settings
SWDTEN = 0;
GODONE = 1;
while(GODONE == 1);
if(ADRESH > THRESH) {
sun = 0;
}
else {
sun = 1;
off = 0;
}
ADCON0 = 0b00001101; // AN3 (BATT)
GODONE = 1;
while(GODONE == 1);
if(ADRESH > 51) {
batt = 0;
}
else {
batt = 1;
}
}
ADCON0 = 0b00001001; // AN2 (LIGHT)
}
}
This is the error it does. I tried googling it for hours, but still cannot find my answer.