This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
testbluthoot [2017/02/16 04:13] leo |
testbluthoot [2019/07/16 19:43] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| [[examplescode|Regresa a codigos]] | [[examplescode|Regresa a codigos]] | ||
| - | <codedoc code:c> | + | <sxh c> |
| - | //Coche fantastico con 6 LEDS | + | /* |
| + | * Prueba del enlace bluetooth. | ||
| + | * Usando Software serial library | ||
| + | */ | ||
| - | #define ROJO1 2 | + | #include <SoftwareSerial.h> |
| - | #define AMARILLO1 3 | + | |
| - | #define VERDE1 4 | + | |
| - | #define ROJO2 5 | + | |
| - | #define AMARILLO2 6 | + | |
| - | #define VERDE2 7 | + | |
| - | int i; | + | SoftwareSerial mySerial(11, 12); // RX, TX |
| void setup() { | void setup() { | ||
| - | pinMode(ROJO1,OUTPUT); | + | // Open serial communications and wait for port to open: |
| - | pinMode(AMARILLO1,OUTPUT); | + | Serial.begin(9600); |
| - | pinMode(VERDE1,OUTPUT); | + | while (!Serial) { |
| - | pinMode(ROJO2,OUTPUT); | + | ; // wait for serial port to connect. Needed for native USB port only |
| - | pinMode(AMARILLO2,OUTPUT); | + | } |
| - | pinMode(VERDE2,OUTPUT); | + | |
| + | |||
| + | Serial.println("Hola buenas noches!"); | ||
| + | |||
| + | // set the data rate for the SoftwareSerial port | ||
| + | mySerial.begin(9600); | ||
| + | mySerial.println("Hola, mundo?"); | ||
| } | } | ||
| - | void loop() { | + | void loop() { // run over and over |
| - | //Recorre luces | + | if (mySerial.available()) { |
| - | for(i=2;i<8;i++){ | + | Serial.write(mySerial.read()); |
| - | digitalWrite(i,HIGH); | + | |
| - | delay(100); | + | |
| - | digitalWrite(i,LOW); | + | |
| - | delay(50); | + | |
| } | } | ||
| - | //Recorre luces reversa | + | if (Serial.available()) { |
| - | for(i=6;i>2;i--){ | + | mySerial.write(Serial.read()); |
| - | digitalWrite(i,HIGH); | + | |
| - | delay(100); | + | |
| - | digitalWrite(i,LOW); | + | |
| - | delay(50); | + | |
| } | } | ||
| } | } | ||
| - | + | </sxh> | |
| - | </codedoc> | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||