Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Two color LED

Status
Not open for further replies.

Djsarkar

Member level 3
Member level 3
Joined
Jul 27, 2020
Messages
55
Helped
0
Reputation
0
Reaction score
1
Trophy points
8
Activity points
301
Hi,

I am looking help to understand following code because I do not understand programming for Arduino

**broken link removed**

I have PIC18F45K80. I am using MPLABX 5.40 and XC8 2.30.

Code:
// Arduino test code:
int redpin = 11; // select the pin for the red LED
int bluepin = 10; // select the pin for the blueLED
int val;
 
void setup () {
  pinMode (redpin, OUTPUT);
  pinMode (bluepin, OUTPUT);
  Serial.begin (9600);
}
 
void loop () {
 for(val=255;val>0;val--) {
   analogWrite (11, val);
   analogWrite (10, 255 - val);
   delay(5);
 }
 for(val=255;val<255;val++) {
    analogWrite (11, val);
    analogWrite (10, 255 - val);
   delay(5);
 }
}

There are two Reverse for loop in code

What's the meaning of following two line in code?

analogWrite (11, val);
analogWrite (10, 255 - val);
 

Hi,

lucky me. I have internet. And an internet search.
I simply input "arduino analogwrite" and get a lot of useful results.

Best is: a link to the original arduino reference.

Try it.
I assume it will work for you, too.

Klaus
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top