Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Project 1"->CA IR-Remote-> Migration Mega2560 to Arduino Uno
#1
so,  Smile
got today my Arduino "Geekcreit® UNO R3 ATmega328P" for only 3€ from

Bangood->"https://www.banggood.com/UNO-R3-ATmega32...64163.html"
(i order there somtimes, because of faster shipping times->is between 7-24 days, and it arrives (2 times now) before 3 weeks)

[Image: arduinouno.jpg]
the "migration" from the Mega2560 to the Uno works "perfectly" (hooray !!)  Smile

but there are some things to notice:

1. connected under Win8.1 i got first an "unknown" usb-device; knew it, but thought it will work anyway..
    had the driver (there also on the site) and u got it a million times in the web, but here again anyway..
    .exe,install,works..
    
.zip   ch341ser.zip (Size: 178.97 KB / Downloads: 0)
2. the "irsend"-pin is on the Uno on "PIN 3" not on Pin9 as the Mega2560...


so, by that i´ve modified the sketch/.ino over the last weeks, and now we have an "initial"-sequence  Smile (which is unneccessary for the function but funny)






and here the modified sketch (works without changes (only pin3 for pin9)) on the Mega2560 and Uno->

.rar   bluetooth-w1-works-list-avmd-ba3-lcdprint3-fi9.rar (Size: 1.39 KB / Downloads: 0)

and here in "clear": (and now with a "Backlight off !!"-function Smile ; means u can set the display "off"/dark).


***********.ino sketch***************


#include <hd44780.h>

#include <SoftwareSerial.h>
#include <IRremote.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

IRsend irsend;
SoftwareSerial BT(10, 11); 
// creates a "virtual" serial port/UART
// connect BT module TX to D10
// connect BT module RX to D11
// connect BT Vcc to 5V, GND to GND
void setup()  
{
  // set digital pin to control as an output
  pinMode(13, OUTPUT);
  // set the data rate for the SoftwareSerial port
  BT.begin(9600);
  lcd.begin(16,2);
  lcd.clear ();
  lcd.print("CA-540 IR Remote!");
  lcd.setCursor(0, 1);
  lcd.print("wait...");
  delay(600);
  //lcd.setCursor(0,1);
  //lcd.print("                           ");
  lcd.setCursor(7,1);
  lcd.blink();
  delay(6500);
  lcd.noBlink();
  lcd.setCursor(0, 1);  
  lcd.print("ready..");
  delay(4500);
  lcd.setCursor(0, 1);  
  lcd.print("                           ");
  lcd.setCursor(0, 1);
  lcd.print("CD!");
  delay(8500);
//  lcd.noBacklight();
  // Send test message to other device
  BT.println("Hello from Arduino");
  BT.println("6 -> Power ON");
  BT.println("8 -> Power OFF");
  BT.println("4 -> DVD/XMOS USB");
  BT.println("1 -> Vol - / down");
  BT.println("2 -> Vol + / up");
  BT.println("3 -> CD");
  BT.println("7 -> Backlight off !!");
  BT.println("9 -> Mute");
  BT.println("5 -> Tuner/Dab 3/Blu-Ray Samsung");
}
char a; // stores incoming character from other device
void loop() 
{
  if (BT.available())
  // if text arrived in from BT serial...
  
  {
    a=(BT.read());
    if (a=='1')
    {
      digitalWrite(13, HIGH);
      BT.println("LED on/Volume Down");
      irsend.sendRC5(0x0000000000000411,12);
      lcd.setCursor(0, 1);  
      lcd.print("                           ");
      lcd.setCursor(0, 1);
      lcd.print("Volume Down");
   lcd.backlight();
    delay(2500);
  //  lcd.noBacklight();
    }
    if (a=='2')
    {
      digitalWrite(13, LOW);
      BT.println("LED off/Volume Up");
      irsend.sendRC5(0x0000000000000410,12);
      lcd.setCursor(0, 1);  
      lcd.print("                           ");
      lcd.setCursor(0, 1);
      lcd.print("Volume Up");
   lcd.backlight();
    delay(2500);      
    }
    if (a=='3')
    {
      digitalWrite(13, HIGH);
      BT.println("CD");
      irsend.sendRC5(0x0000000000000405,12);
      lcd.setCursor(0, 1);  
      lcd.print("                           ");
      lcd.setCursor(0, 1);
      lcd.print("CD !");
      lcd.backlight();
    delay(2500);
    //lcd.noBacklight();
    }
    if (a=='4')
    {
      digitalWrite(13, HIGH);
      BT.println("DVD-XMOS-USB");
      irsend.sendRC5(0x0000000000000401,12);
      lcd.setCursor(0, 1);  
      lcd.print("                           ");
      lcd.setCursor(0, 1);
      lcd.print("DVD-XMOS-USB");
   lcd.backlight();
    delay(2500);
    }    
    if (a=='5')
    {
      digitalWrite(13, LOW);
      BT.println("Tuner/Dab 3/Blu-Ray-Samsung");
      irsend.sendRC5(0x0000000000000403,12);
      lcd.setCursor(0, 1);  
      lcd.print("                           ");
      lcd.setCursor(0, 1);
      lcd.print("Tuner/Dab 3/Blu-Ray-Samsung !");
   lcd.backlight();
    delay(2500);
    }
    if (a=='6')
    {
      digitalWrite(13, HIGH);
      BT.println("Power ON");
      irsend.sendRC5(0x000000000000040e,12);
      lcd.setCursor(0, 1);  
      lcd.print("                           ");
      lcd.setCursor(0, 1);
      lcd.print("Power ON !");
   lcd.backlight();
    delay(2500);
    }
    if (a=='7')
    {
      digitalWrite(13, LOW);
      BT.println("Backlight off !!");
      lcd.setCursor(0, 1);  
      lcd.print("                           ");
            lcd.setCursor(0, 1);
      lcd.print("Backlight off !!");
   lcd.backlight();
    delay(4500);
    lcd.noBacklight();
    }
    if (a=='8')
    {
      digitalWrite(13, LOW);
      BT.println("Power off");
      irsend.sendRC5(0x000000000000040f,12);
      lcd.setCursor(0, 1);  
      lcd.print("                           ");
      lcd.setCursor(0, 1);
      lcd.print("Power off !!");
   lcd.backlight();
    delay(2500);
    }
    if (a=='9')
    {
      digitalWrite(13, LOW);
      BT.println("AV/MD/Mini-DAC");
      irsend.sendRC5(0x0000000000000402,12);
      lcd.setCursor(0, 1);  
      lcd.print("                           ");
      lcd.setCursor(0, 1);
      lcd.print("AV/MD/Mini-DAC !");
   lcd.backlight();
    delay(2500);
    }
         
    if (a=='0')
    {
      digitalWrite(13, LOW);
      BT.println("Hello from Arduino");
      BT.println("6 -> Power ON");
      BT.println("8 -> Power OFF");
      BT.println("4 -> DVD/XMOS USB");
      BT.println("1 -> Vol - / down");
      BT.println("2 -> Vol + / up");
      BT.println("3 -> CD");
      BT.println("7 -> Backlight off !!");
      BT.println("9 -> AV/MD/Mini-DAC");
      BT.println("5 -> Tuner/Dab 3/Blu-Ray Samsung");
      lcd.backlight();
      lcd.setCursor(0, 1);  
      lcd.print("                           ");
      lcd.setCursor(0, 1);
      lcd.print("Info !!(via BT)");
    delay(5000);
       
          }
    if (a=='?')
    {
      BT.println("Send '1' to turn LED on");
      BT.println("Send '2' to turn LED on");
    }   
    // you can add more "if" statements with other characters to add more commands
  }
}


************ end sketch *************
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)