About Arduino control 11 Bits
Esta aplicacion fue desarrollada para funcionar con ATMEGA2560, pero puede funcionar tambien con otras versiones de arduino, como lo son arduino uno, arduino nano.
Los materiales necesarios son:
Arduino ATMEGA2560.
HC-05 Puerto com bluetooth.
Celular android.
El programa del arduino:
// Definicion de pines de arduino a usar.
byte BIT0=2;
byte BIT1=3;
byte BIT2=4;
byte BIT3=5;
byte BIT4=6;
byte BIT5=7;
byte BIT6=8;
byte BIT7=9;
byte BIT8=10;
byte BIT9=11;
byte BIT10=12;
int Entrada=0; // Byte de entrada por puerto serial
void setup()
{
// Arranque de puerto serial, el puerto a utilizar es el puerto 1, que corresponde a los pines RX=18 y TX=19 para arduino ATMEGA2560, si desea cambiar el puerto modificar Serial1.begin
// Cambiar el numero "1" por el numero del puerto a utilizar.
Serial1.begin(9600);
pinMode(BIT0, OUTPUT);
pinMode(BIT1, OUTPUT);
pinMode(BIT2, OUTPUT);
pinMode(BIT3, OUTPUT);
pinMode(BIT4, OUTPUT);
pinMode(BIT5, OUTPUT);
pinMode(BIT6, OUTPUT);
pinMode(BIT7, OUTPUT);
}
void loop()
{
if (Serial1.available() > 0) {
Entrada = Serial1.read(); // get incoming byte:
if(Entrada == 'A'){
digitalWrite(BIT0, HIGH); // switch on LED
Serial1.print('A'); // send a char
delay(100);
digitalWrite(BIT0,LOW);
}
if(Entrada == 'B'){
digitalWrite(BIT1, HIGH); // switch on LED
Serial1.print('B'); // send a char
delay(100);
digitalWrite(BIT1,LOW);
}
if(Entrada == 'C'){
digitalWrite(BIT2, HIGH); // switch on LED
Serial1.print('C'); // send a char
delay(100);
digitalWrite(BIT2,LOW);
}
if(Entrada == 'D'){
digitalWrite(BIT3, HIGH); // switch on LED
Serial1.print('D'); // send a char
delay(100);
digitalWrite(BIT3,LOW);
}
if(Entrada == 'E'){
digitalWrite(BIT4, HIGH); // switch on LED
Serial1.print('E'); // send a char
delay(100);
digitalWrite(BIT4,LOW);
}
if(Entrada == 'F'){
digitalWrite(BIT5, HIGH); // switch on LED
Serial1.print('F'); // send a char
delay(100);
digitalWrite(BIT5,LOW);
}
if(Entrada == 'G'){
digitalWrite(BIT6, HIGH); // switch on LED
Serial1.print('G'); // send a char
delay(100);
digitalWrite(BIT6,LOW);
}
if(Entrada == 'H'){
digitalWrite(BIT7, HIGH); // switch on LED
Serial1.print('H'); // send a char
delay(100);
digitalWrite(BIT7,LOW);
}
if(Entrada == 'I'){
digitalWrite(BIT8, HIGH); // switch on LED
Serial1.print('I'); // send a char
delay(100);
digitalWrite(BIT8,LOW);
}
if(Entrada == 'J'){
digitalWrite(BIT9, HIGH); // switch on LED
Serial1.print('J'); // send a char
delay(100);
digitalWrite(BIT9,LOW);
}
if(Entrada == 'K'){
digitalWrite(BIT10, HIGH); // switch on LED
Serial1.print('K'); // send a char
delay(100);
digitalWrite(BIT10,LOW);
}
}
} This application was developed to run on ATmega2560, but can also work with other versions of Arduino, such as Arduino Uno, Arduino Nano.
The materials needed are:
Arduino ATmega2560.
HC-05 Bluetooth COM port.
Android cell.
The Arduino program:
// Definition of Arduino pins to use.
byte BIT0 = 2;
byte BIT1 = 3;
byte BIT2 = 4;
byte BIT3 = 5;
byte BIT4 = 6;
Bit5 byte = 7;
bit6 byte = 8;
BIT7 byte = 9;
bit8 byte = 10;
Bit9 byte = 11;
Bit10 byte = 12;
Input int = 0; // Byte serial input port
void setup ()
{
// Start serial port, the port to use is port 1, corresponding to the RX and TX = 18 = 19 for ATmega2560 Arduino pins, if you want to change the port change Serial1.begin
// Change the number "1" for the port number to use.
Serial1.begin (9600);
pinMode (BIT0, OUTPUT);
pinMode (BIT1, OUTPUT);
pinMode (BIT2, OUTPUT);
pinMode (BIT3, OUTPUT);
pinMode (BIT4, OUTPUT);
pinMode (bit5, OUTPUT);
pinMode (bit6, OUTPUT);
pinMode (BIT7, OUTPUT);
}
void loop ()
{
if (Serial1.available ()> 0) {
Serial1.read input = (); // Get incoming byte:
if (input == 'A') {
digitalWrite (BIT0, HIGH); // Switch on LED
Serial1.print ('A'); // Send to char
delay (100);
digitalWrite (BIT0, LOW);
}
if (input == 'B') {
digitalWrite (BIT1, HIGH); // Switch on LED
Serial1.print ('B'); // Send to char
delay (100);
digitalWrite (BIT1, LOW);
}
if (input == 'C') {
digitalWrite (BIT2, HIGH); // Switch on LED
Serial1.print ('C'); // Send to char
delay (100);
digitalWrite (BIT2, LOW);
}
if (input == 'D') {
digitalWrite (BIT3, HIGH); // Switch on LED
Serial1.print ('D'); // Send to char
delay (100);
digitalWrite (BIT3, LOW);
}
if (input == 'E') {
digitalWrite (BIT4, HIGH); // Switch on LED
Serial1.print ('E'); // Send to char
delay (100);
digitalWrite (BIT4, LOW);
}
if (input == 'F') {
digitalWrite (bit5, HIGH); // Switch on LED
Serial1.print ('F'); // Send to char
delay (100);
digitalWrite (bit5, LOW);
}
if (input == 'G') {
digitalWrite (bit6, HIGH); // Switch on LED
Serial1.print ('G'); // Send to char
delay (100);
digitalWrite (bit6, LOW);
}
if (input == 'H') {
digitalWrite (BIT7, HIGH); // Switch on LED
Serial1.print ('H'); // Send to char
delay (100);
digitalWrite (BIT7, LOW);
}
if (input == 'I') {
digitalWrite (bit8, HIGH); // Switch on LED
Serial1.print ('I'); // Send to char
delay (100);
digitalWrite (bit8, LOW);
}
if (input == 'J') {
digitalWrite (Bit9, HIGH); // Switch on LED
Serial1.print ('J'); // Send to char
delay (100);
digitalWrite (Bit9, LOW);
}
if (input == 'K') {
digitalWrite (Bit10, HIGH); // Switch on LED
Serial1.print ('K'); // Send to char
delay (100);
digitalWrite (Bit10, LOW);
}
}
}