week16

parent 7d59260f
Pipeline #94015 passed with stage
in 21 seconds
#include <SoftwareSerial.h>
SoftwareSerial myserial(8,7);
int led1=5;
int led2=6;
int led3=9;
void setup() {
// put your setup code here, to run once:
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
myserial.begin(9600);
digitalWrite(led1,HIGH);
digitalWrite(led2,HIGH);
digitalWrite(led3,HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
if (myserial.available()>0){
int input=myserial.read();
if (input=='1'){
digitalWrite(led1,LOW);
}
else{
digitalWrite(led1,HIGH);
}
if (input=='2'){
digitalWrite(led2,LOW);
}
else{
digitalWrite(led2,HIGH);
}
if (input=='3'){
digitalWrite(led3,LOW);
}
else{
digitalWrite(led3,HIGH);
}
}
}
#include <SoftwareSerial.h>
SoftwareSerial myserial(8,7);
byte u,d,k,p,u1,d1,k1,p1,u2,d2,k2,p2;
int ledr=5;
int ledg=6;
int ledb=9;
int valor;
void setup() {
pinMode(ledr, OUTPUT);
pinMode(ledg, OUTPUT);
pinMode(ledb, OUTPUT);
myserial.begin(9600);
}
void loop() {
if (myserial.available() > 0) {
valor = myserial.read();
if (valor == 'r'){ //If para LED Rojo
delay(10);
k=myserial.read()-48;
delay(10);
d=myserial.read()-48;
delay(10);
u=myserial.read()-48;
p=(100*k)+(10*d)+u;
analogWrite(ledr, p);
Serial.println(p);
}
if (valor == 'g'){ //If para LED Verde
delay(10);
k1=myserial.read()-48;
delay(10);
d1=myserial.read()-48;
delay(10);
u1=myserial.read()-48;
p1=(100*k1)+(10*d1)+u1;
analogWrite(ledg, p1);
}
if (valor == 'b'){ //If para LED Azul
delay(10);
k2=myserial.read()-48;
delay(10);
d2=myserial.read()-48;
delay(10);
u2=myserial.read()-48;
p2=(100*k2)+(10*d2)+u2;
analogWrite(ledb, p2);
}
}
}
......@@ -68,7 +68,7 @@
<h2>Download</h2>
<p>
You can download this files Here: <br>
<a href="images/week14/arducnc.sch" download>Schematic.</a><br>
<a href="images/week15/arducnc.sch" download>Schematic.</a><br>
</p>
</p>
......
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment