Tengo un proyecto escolar y ya tengo el código listo y funcional, pero quiero mandar la información que me aparece en mi puerto com a mi nodem cu y de ahí a thinkspeak alguien me podría ayudar???`
ANEXO CODIGO DE MI ARDUINO UNO
#include <Servo.h>
#define S0 2
#define S1 3
#define S2 4
#define S3 5
#define sensorOut 6
Servo topServo;
Servo bottomServo;
int frequency = 0;
int color=0;
int contador = 0;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int trigPin = 9;
const int echoPin = 10;
long duracion;
int distancia;
int ultimaDistancia = 0;
LiquidCrystal_I2C lcd(0x27,16,2);
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
lcd.init();
lcd.backlight();
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);
// Setting frequency-scaling to 20%
digitalWrite(S0, HIGH);
digitalWrite(S1, LOW);
topServo.attach(7);
bottomServo.attach(8);
Serial.begin(9600);
}
void loop() {
topServo.write(115);
delay(50);
for(int i = 115; i > 65; i--) {
topServo.write(i);
delay(10);
}
delay(50);
color = readColor();
delay(500);
switch (color) {
case 1:
bottomServo.write(50);
break;
case 2:
bottomServo.write(75);
break;
case 3:
bottomServo.write(100);
break;
case 4:
bottomServo.write(125);
break;
case 5:
bottomServo.write(150);
break;
case 6:
bottomServo.write(175);
break;
case 0:
break;
}
delay(30);
for(int i = 65; i > 29; i--) {
topServo.write(i);
delay(10);
}
for(int i = 29; i < 115; i++) {
topServo.write(i);
delay(20);
}
color=0;
}
// Custom Function - readColor()
int readColor() {
// Setting red filtered photodiodes to be read
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int R = frequency;
// Printing the value on the serial monitor
Serial.print("R= ");//printing name
Serial.print(frequency);//printing RED color frequency
Serial.print(" ");
delay(50);
lcd.setCursor(0,1);
lcd.print("R="); // Prints string "Distance" on the LCD
lcd.print(frequency);
lcd.print("%");
// Setting Green filtered photodiodes to be read
digitalWrite(S2, HIGH);
digitalWrite(S3, HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int V = frequency;
// Printing the value on the serial monitor
Serial.print("V= ");//printing name
Serial.print(frequency);//printing RED color frequency
Serial.print(" ");
delay(50);
lcd.setCursor(6,1);
lcd.print("V="); // Prints string "Distance" on the LCD
lcd.print(frequency);
lcd.print("%");
// Setting Blue filtered photodiodes to be read
digitalWrite(S2, LOW);
digitalWrite(S3, HIGH);
// Reading the output frequency
frequency = pulseIn(sensorOut, LOW);
int A = frequency;
// Printing the value on the serial monitor
Serial.print("A= ");//printing name
Serial.print(frequency);//printing RED color frequency
Serial.println(" ");
lcd.setCursor(11,1);
lcd.print("A="); // Prints string "Distance" on the LCD
lcd.print(frequency);
lcd.print("%");
delay(50);
if(R<45 & R>32 & V<65 & V>55){
color = 1; // Red
}
if(V<55 & V>43 & A<47 &A>35){
color = 2; // Orange
}
if(R<53 & R>40 & V<53 & V>40){
color = 3; // Green
}
if(R<38 & R>24 & V<44 & V>30){
color = 4; // Yellow
}
if(R<56 & R>46 & V<65 & V>55){
color = 5; // Brown
}
if (V<58 & V>45 & A<40 &A>26){
color = 6; // Blue
}
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duracion = pulseIn(echoPin, HIGH);
distancia = (duracion * 0.034) / 2;
Serial.println(distancia);
if(distancia != ultimaDistancia)
lcd.setCursor(0,0);
lcd.print("Cap:"); // Prints string "Distance" on the LCD
lcd.print(distancia);
( ultimaDistancia = distancia);
Serial.println(contador++);
lcd.setCursor(7,0);
lcd.print("Tapas:"); // Prints string "Distance" on the LCD
lcd.print(contador);
delay(50);
return color;
}