Issue with using the adafruit motorshield v1 library - arduino

I am new to microcontrollers programming. I just got my hands on the arduino uno board. I am trying to build the popular "bluetooth robot car" using the uno, adafruit motorshield v1 and HC-05 bluetooth module. My code attached below compiles and uploads without any error or warning. While not stacking the shield and not attaching the bluetooth module, instead seeing "Robot remote control mode" on the serial monitor, I see some "Rbnld tedisjvv shhsjj hshhs". When I attach and connect the bluetooth module and send a command 'R', instead of seeing 'R' on the monitor I see 'R' followed by an up-pointing arrow. I have searched for help on the web on similar problems but none has helped. I have tried other codes for serial communication(like blinking an led when 'B' is read from serial) and it worked perfectly.I need help.
// include the Adafruit motor v1 library
#include <AFMotor.h>
AF_DCMotor MotorFR(1); // Motor for drive Front Right on M1
AF_DCMotor MotorFL(2); // Motor for drive Front Left on M2
AF_DCMotor MotorBL(3); // Motor for drive Back Left on M3
AF_DCMotor MotorBR(4); // Motor for drive Back Right on M4
const int buzPin = 2; // set digital pin 2 as buzzer pin (use active buzzer)
const int ledPin = A5; // set digital pin A5 as LED pin (use super bright LED)
int valSpeed = 255;
void setup(){
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("*Robot Remote Control Mode*");
pinMode(buzPin, OUTPUT); // sets the buzzer pin as an Output
pinMode(ledPin, OUTPUT); // sets the LED pin as an Output
// Set the speed to start, from 0 (off) to 255 (max speed)
MotorFL.setSpeed(valSpeed);
MotorFR.setSpeed(valSpeed);
MotorBL.setSpeed(valSpeed);
MotorBR.setSpeed(valSpeed);
// turn off motor
MotorFL.run(RELEASE);
MotorFR.run(RELEASE);
MotorBL.run(RELEASE);
MotorBR.run(RELEASE);
}
void loop() {
while (Serial.available() > 0) {
char command = Serial.read(); // gets one byte from serial buffer
Serial.println(command);
switch(command){
case 'F': // move forward
SetSpeed(valSpeed);
MotorFL.run(FORWARD);
MotorFR.run(FORWARD);
MotorBL.run(FORWARD);
MotorBR.run(FORWARD);
break;
case 'B': // move backward
SetSpeed(valSpeed);
MotorFL.run(BACKWARD);
MotorFR.run(BACKWARD);
MotorBL.run(BACKWARD);
MotorBR.run(BACKWARD);
break;
case 'R': // turn right
SetSpeed(valSpeed);
MotorFL.run(FORWARD);
MotorFR.run(BACKWARD);
MotorBL.run(FORWARD);
MotorBR.run(BACKWARD);
break;
case 'L': // turn left
SetSpeed(valSpeed);
MotorFL.run(BACKWARD);
MotorFR.run(FORWARD);
MotorBL.run(BACKWARD);
MotorBR.run(FORWARD);
break;
case 'G': // forward left
MotorFL.setSpeed(valSpeed/4);
MotorBL.setSpeed(valSpeed/4);
MotorFL.run(FORWARD);
MotorFR.run(FORWARD);
MotorBL.run(FORWARD);
MotorBR.run(FORWARD);
break;
case 'H': // backward left
MotorFL.setSpeed(valSpeed/4);
MotorBL.setSpeed(valSpeed/4);
MotorFL.run(BACKWARD);
MotorFR.run(BACKWARD);
MotorBL.run(BACKWARD);
MotorBR.run(BACKWARD);
break;
case 'I': // forward right
MotorFR.setSpeed(valSpeed/4);
MotorBR.setSpeed(valSpeed/4);
MotorFL.run(FORWARD);
MotorFR.run(FORWARD);
MotorBL.run(FORWARD);
MotorBR.run(FORWARD);
break;
case 'J': // backward right
MotorFR.setSpeed(valSpeed/4);
MotorBR.setSpeed(valSpeed/4);
MotorFL.run(BACKWARD);
MotorFR.run(BACKWARD);
MotorBL.run(BACKWARD);
MotorBR.run(BACKWARD);
break;
case 'S': // stop
MotorFL.run(RELEASE);
MotorFR.run(RELEASE);
MotorBL.run(RELEASE);
MotorBR.run(RELEASE);
break;
case 'V': // beep buzzer
digitalWrite(buzPin, HIGH);
delay(150);
digitalWrite(buzPin, LOW);
delay(100);
digitalWrite(buzPin, HIGH);
delay(250);
digitalWrite(buzPin, LOW);
break;
case 'W': // turn light on
digitalWrite(ledPin, HIGH);
break;
case 'w': // turn light off
digitalWrite(ledPin, LOW);
break;
case '0': // set speed motor to 0 (min)
SetSpeed(0);
break;
case '1': // set speed motor to 30
SetSpeed(30);
break;
case '2': // set speed motor to 55
SetSpeed(55);
break;
case '3': // set speed motor to 80
SetSpeed(80);
break;
case '4': // set speed motor to 105
SetSpeed(105);
break;
case '5': // set speed motor to 130
SetSpeed(130);
break;
case '6': // set speed motor to 155
SetSpeed(155);
break;
case '7': // set speed motor to 180
SetSpeed(180);
break;
case '8': // set speed motor to 205
SetSpeed(205);
break;
case '9': // set speed motor to 230
SetSpeed(230);
break;
case 'q': // set speed motor to 255 (max)
SetSpeed(255);
break;
}
}
}
// function for setting speed of motors
void SetSpeed(int val){
valSpeed = val;
MotorFL.setSpeed(val);
MotorFR.setSpeed(val);
MotorBL.setSpeed(val);
MotorBR.setSpeed(val);
}```

Related

DF Player Mini on Arduino Uno Not Playing

I have a problem which is driving me crazy .I want to use dfmini player to play Songs on the arduino and output it on a 8 ohm 0.5W Speaker , and nothing is working .I am using the DFRobotDFPlayerMini Library code as is but nothing is playing at all .Here is a photo of my connections.
Image Here
I apologize if my photo is not clear as i don't have time for software drawing, and i didnt use a breadboard as actually the DF Player is slightly bigger than the holes.
The Arduino Pins Used is 11,10 and 5V and 2 Pins for the GND
Here is the Code of the DFRobot Library used as is .
The Files on the SD Card are in a folder mp3 and written as 0001.mp3 0002.mp3 ..etc
When i Connect and try it out . The Blue Led on MP3 Player doesn't light up , and on the Serial Monitor Baud 115200 :
DFRobot DFPlayer Mini
DFRobot DFPlayer Mini Demo
Initializing DFPlayer ... (May take 3~5 seconds)
DFPlayer Mini online.
and on Serial Monitor Baud 9600:
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮ܙf⸮⸮⸮⸮⸮⸮⸮⸮
Would be very thankful if anyone can solve this problem.
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);
void setup()
{
mySoftwareSerial.begin(9600);
Serial.begin(115200);
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
if (!myDFPlayer.begin(mySoftwareSerial, false)) { //Use softwareSerial to communicate with mp3.
Serial.println(F("Unable to begin:"));
Serial.println(F("1.Please recheck the connection!"));
Serial.println(F("2.Please insert the SD card!"));
while(true){
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
Serial.println(F("DFPlayer Mini online."));
myDFPlayer.volume(10); //Set volume value. From 0 to 30
myDFPlayer.play(1); //Play the first mp3
}
void loop()
{
static unsigned long timer = millis();
if (millis() - timer > 3000) {
timer = millis();
myDFPlayer.next(); //Play next mp3 every 3 second.
}
if (myDFPlayer.available()) {
printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
}
}
void printDetail(uint8_t type, int value){
switch (type) {
case TimeOut:
Serial.println(F("Time Out!"));
break;
case WrongStack:
Serial.println(F("Stack Wrong!"));
break;
case DFPlayerCardInserted:
Serial.println(F("Card Inserted!"));
break;
case DFPlayerCardRemoved:
Serial.println(F("Card Removed!"));
break;
case DFPlayerCardOnline:
Serial.println(F("Card Online!"));
break;
case DFPlayerUSBInserted:
Serial.println("USB Inserted!");
break;
case DFPlayerUSBRemoved:
Serial.println("USB Removed!");
break;
case DFPlayerPlayFinished:
Serial.print(F("Number:"));
Serial.print(value);
Serial.println(F(" Play Finished!"));
break;
case DFPlayerError:
Serial.print(F("DFPlayerError:"));
switch (value) {
case Busy:
Serial.println(F("Card not found"));
break;
case Sleeping:
Serial.println(F("Sleeping"));
break;
case SerialWrongStack:
Serial.println(F("Get Wrong Stack"));
break;
case CheckSumNotMatch:
Serial.println(F("Check Sum Not Match"));
break;
case FileIndexOut:
Serial.println(F("File Index Out of Bound"));
break;
case FileMismatch:
Serial.println(F("Cannot Find File"));
break;
case Advertise:
Serial.println(F("In Advertise"));
break;
default:
break;
}
break;
default:
break;
}
}
Try changing:
if (!myDFPlayer.begin(mySoftwareSerial, false))
to:
if (!myDFPlayer.begin(mySoftwareSerial, true, false))
The problem as it appeared was in the Arduino Cable , Make Sure that the cable itself is working properly

send sms with sim900 using arduino

#include <Password.h>
#include <Keypad.h>
#include <Servo.h>
#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
Servo myservo;
Password password = Password( "1234" ); //password to unlock box, can be changed
SMSGSM sms;
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
const byte ROWS = 4;
const byte COLS = 4;
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 9, 8, 7, 6 };// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 5, 4, 3, 2 };
int x=0;
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() //if i add sms(); function it workssss
{
Serial.begin(9600); //Start a Serial COM
Serial.println(F("ARDUINO SECURITY SYSTEM V1.0"));
Serial.print(F("Checking GSM COM..."));
if (gsm.begin(9600)) //Start the GSM COM
{
(sms.SendSMS("+XXXXX","Your Home Security system is powered up"));
Serial.println(F("Good To GO!!"));
}
else
{
Serial.println(F("Could not connect to GSM modem"));
}
Serial.write(254);
Serial.write(0x01);
delay(200);
pinMode(11, OUTPUT); //green light
pinMode(12, OUTPUT); //red light
myservo.attach(13); //servo on digital pin 9 //servo
keypad.addEventListener(keypadEvent);//add an event listener for this keypad
}
void loop(){
keypad.getKey();
myservo.write(0);
}
//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
Serial.print("Enter : ");
Serial.println(eKey);
delay(10);
Serial.write(254);
switch (eKey){
case 'A': checkPassword(); delay(1); break;
case 'C': checkPassword(); delay(1); break;
case 'D': checkPassword(); delay(1); break;
case 'B': password.reset(); delay(1); break;
case '*': checkPassword(); break;
case '#': password.reset(); break;
default: password.append(eKey); delay(1);
}
}
}
void checkPassword(){
if (password.evaluate()){ //if password is right open box
Serial.println("Accepted");
Serial.write(254);delay(50);
//Add code to run if it works
myservo.write(5); //160deg
digitalWrite(11, HIGH);//turn on
delay(2000); //wait 5 seconds
digitalWrite(11, LOW);// turn off
}
else
{
Serial.println("Denied"); //if passwords wrong keep box locked
Serial.write(254);delay(10);
x++;
if(x==3)
//add code to run if it did not work
{
myservo.write(0);
digitalWrite(12, HIGH);
delay(500);
digitalWrite(12, LOW);
if (gsm.begin(9600))
{
(sms.SendSMS("+XXXXX","Your Home Security system is being bridged"));
Serial.println("USER WARNED");
}
}
}
}
;
}
In the picture the same code doesn't seem to work when I place the lines
if (gsm.begin(9600)) //Start the GSM COM
{
(sms.SendSMS("+8613668914901","Your Home Security system is being bridged"));
but this lines work great inside the void setup function.
How can I fix this problem? Inside the void setup the sketch works fine but when I also put the code in the function CheckPassword it doesn't send SMS.
I also tried to create a function let's say void SMS and call it in the checkPassword function but it doesn't solve the problem, btw the same function when called in the void setup works fine.
You are supposed to initialize the gsm only once, in the setup function.
In your code you attempt to initialize it again in the checkPassword method, and that is obviously not going to work.
Thus you should remove the line gsm.begin(9600) from the checkPassword function.
UPDATE 1:
In your scheme you reserve the pins 9, 8, 7, 6, 5, 4, 3, 2 for the Keyboard. However, at the same time you reserve pins 2, 3 for your GSM module (see GSM.cpp):
#define _GSM_TXPIN_ 2
#define _GSM_RXPIN_ 3
Using the same pins for multiple purposes can often result (if not done properly) in undefined behaviour which in the best scenario means that your sketch isn't doing what it is supposed to do, and in the worst scenario it might damage your components.
You are already using pins 0, 1 for the Serial library, but according to your code the pins 10, 11, 13 should still be free if you want to relocate the existing pins to your components.
Notice also the following warnings inside the GSM library:
[3] My shield doesn't work. Why?
Check this steps and then ask for support on the issues' page on google
code.
1) SIM900 and SIM908 require about 1 A during the hardest tasks.
You should have an external power source that can provide about
1 A at 8-12 V
2) If the SIM90X blinks (1 Hz) for some seconds and then turn off,
probably it's a communication's problem. Check the switch/jumpers
for Serial communication.
3) Arduino Uno has 2 KB of RAM. Library takes about 80% (we are working
to reduce it), if you use more than 20% left, Arduino can restart
or print on serial strange strings.
4) Check the jumper of communication, power source (battery or externel) and charge.

Arduino Serial.read() from xbee if statement

I am trying to finish a small project with a moisture sensor connected to a Fio V3.
I have also attach a Xbee S1 module to Fio's socket.
I have upload the following code to Fio:
int igrasia = 7;
void setup()
{
Serial1.begin(9600);
pinMode(igrasia, INPUT_PULLUP);
}
void loop(){
int sensorVal = digitalRead(igrasia);
if (sensorVal == HIGH) {
Serial1.println("0"); // Send OK to xbee
}
else {
Serial1.println("1"); // Send NOT OK to xbee
}
delay(5000);
}
On my computer using the Xbee USB explorer I am receiving correct data on X-CTU every 5 seconds.
Zero (0) while the sensor is outside a glass of water and one (1) while the sensor is in the glass of water.
I want to read these bytes to an Arduino Uno with a LCD screen attached and an Xbee shield. For this reason I have uploaded to Uno the following code:
#include <SPI.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x38,16,2); // set the LCD address to 0x20 for a 16 chars
void setup(){
Serial.begin(9600);
//configure pin2 as an input and enable the internal pull-up resistor
// pinMode(8, INPUT_PULLUP);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
lcd.init(); // initialize the lcd
}
void loop(){
if(Serial.available())
{
char getData = Serial.read();
if (getData == '1')
{
Serial.print(getData);
digitalWrite(13, HIGH);
lcd.clear();
lcd.setCursor (0,0); // go to start of 1st line
lcd.print("ATTENTION !!!!");
lcd.setCursor (0,1); // go to start of 1st line
lcd.print("WET environment");
}
else {
Serial.print(getData);
digitalWrite(13, LOW);
lcd.clear();
lcd.setCursor (0,0); // go to start of 1st line
lcd.print("dry environment");
lcd.setCursor (0,1); // go to start of 1st line
lcd.print("all looks good!");
}
}
}
It doesn't work properly :- (
I have correct functionality for 0 and while the sensor is outside the water. LCD monitor shows "dry environment".
But as soon as I place the sensor in the water, LCD is not working as required.
Even if I leave the sensor in the water the LCD still displays "dry environment".
I tried the sensor connected directly to Uno with the LCD attached and it works!
I suppose something is wrong with the serial.read() and/or my If / loop statement on UNO.
Any suggestions or advice?
When you transmit the data, you're sending it as a String "1", "0".
On the receiver, you're testing for characters '1', '0'. Strings are terminated with a null character (/u0000), whereas characters are not. Therefore the condition is always failed. You could try transmitting and testing characters only.

Why is my Arduino freezing when using a relay board?

I'm working on a project where I use midi notes to switch 8 old lamps using the Arduino Uno. I've built a case with 8 wall sockets that are linked up to a relay board for the Arduino. I am using the Hairless midi serial bridge to send midi notes via USB to the Arduino.
This all works until I put power on the sockets with my Uno. After about 5~10 seconds the Arduino freezes. The relay shield stays in it's current state and the indication lights for serial communication stop flashing. When there isn't 220 volts going through the relays it all works great.
(My schematics are below.) The Arduino is powered via USB. I also tried powering the Arduino with an additional adapter of 5V and 500mA but that didn't make a difference.
Code:
#include <digitalWriteFast.h>
byte incomingByte=0;
byte notebyte=0;
byte velocitybyte=0;
byte statusbuffer=0;
byte NOTE_ON = 144;
byte NOTE_OFF = 128;
boolean arp_triggernext=false;
boolean firstbyte;
void MIDI_Poll(){
if (Serial.available() > 0) {
do {
// read the incoming byte:
incomingByte = Serial.read();
if (incomingByte>247) {
// this is where MIDI clock stuff is done
switch (incomingByte){
}
}
else if (incomingByte>240) {
statusbuffer = 0;
//sysex stuff done here
}
else if (incomingByte>127) {
statusbuffer = incomingByte;
firstbyte = true;
notebyte = 0;
velocitybyte = 0;
}
else if (statusbuffer!=0) {
if (firstbyte == true) {
// must be first byte
notebyte = incomingByte;
firstbyte = false;
}
else {
// so must be second byte then
velocitybyte = incomingByte;
//process the message here
if (statusbuffer == NOTE_ON && velocitybyte != 0) {
switch (notebyte) {
case 60:
digitalWriteFast2(2, HIGH);
break;
case 61:
digitalWriteFast2(3, HIGH);
break;
case 62:
digitalWriteFast2(4, HIGH);
break;
case 63:
digitalWriteFast2(5, HIGH);
break;
case 64:
digitalWriteFast2(6, HIGH);
break;
case 65:
digitalWriteFast2(7, HIGH);
break;
case 66:
digitalWriteFast2(8, HIGH);
break;
case 67:
digitalWriteFast2(9, HIGH);
break;
}
}
else if (statusbuffer == NOTE_OFF || (statusbuffer == NOTE_ON && velocitybyte == 0)) {
switch (notebyte){
case 60:
digitalWriteFast2(2, LOW);
break;
case 61:
digitalWriteFast2(3, LOW);
break;
case 62:
digitalWriteFast2(4, LOW);
break;
case 63:
digitalWriteFast2(5, LOW);
break;
case 64:
digitalWriteFast2(6, LOW);
break;
case 65:
digitalWriteFast2(7, LOW);
break;
case 66:
digitalWriteFast2(8, LOW);
break;
case 67:
digitalWriteFast2(9, LOW);
break;
}
}
//now clear them for next note
notebyte = 0;
velocitybyte = 0;
firstbyte = true;
}
}
} while (Serial.available() > 0);
}
}
void setup() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
Serial.begin(9600);
}
void loop() {
MIDI_Poll();
}
It's based on code I've found for processing serial midi.
I'm really confused as to why this happens. I want to know why my Arduino and relay board freeze when there is 220 volts going through the relays.
Materials:
Arduino Uno revision 3
Relay board with 8 relays switched with 5 volt. Capable of handling 10A. Bought here: https://iprototype.nl/products/components/buttons-switches/relay-board-8-channels-5v
8 normal wallsockets powered with 220 volts
8 light bulbs with E27 fitting
As I am seeing here is some circuit issues so i am going to explain them 1 by 1
1. you should not run relay directly from Arduino pin so use appropriate circuit with transistor to run a relay and use arduino pin as a sink not a source will be better.
2.use a freewheeling diode with relay coil.
3.use optoisolator at Rx and Tx.

arduino program runs only at start up

My arduino program runs only when on start up or when i press the reset button, i dont know the problem as i am a new bee into this. Please need help.
i have some constants here for the remote control, and i am just trying to replicate what i am sending through the arduino ir led, every thing works fine except that the program runs only once.
#include <IRremote.h> // use the library
#define PanasonicAddress 0x4004 // Panasonic address (Pre data)
#define PanasonicPower 0x100BCBD // Panasonic Power button
#define PanasonicZero 0x1009899 // Panasonic button
#define PanasonicOne 0x1000809 // Panasonic button
#define PanasonicTwo 0x1008889 // Panasonic button
#define PanasonicThree 0x1004849 // Panasonic button
#define PanasonicFour 0x100C8C9 // Panasonic button
#define PanasonicFive 0x1002829 // Panasonic button
#define PanasonicSix 0x100A8A9 // Panasonic button
#define PanasonicSeven 0x1006869 // Panasonic button
#define PanasonicEight 0x100E8E9 // Panasonic button
#define PanasonicNine 0x1001819 // Panasonic button
#define PMute 0x1004C4D
#define PCPlus 0x1002C2D
#define PCMinus 0x100ACAD
#define PVMinus 0x1008485
#define PVPlus 0x1000405
#define PRTune 0x100ECED
#define JVCPower 0xC5E8
int receiverpin = 15; // pin 1 of IR receiver to Arduino digital pin 15
IRsend irsend;
IRrecv irrecv(receiverpin); // create instance of irrecv
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // start the IR receiver
// pinMode(7, OUTPUT);
for (int z = 11 ; z < 14 ; z++) // set up digital pins
{
pinMode(z, OUTPUT);
}
}
void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
translateIR();
for (int z = 0 ; z < 2 ; z++) // ignore the repeated codes
{
irrecv.resume(); // receive the next value
}
}
}
void translateIR()
// takes action based on IR code received
// uses Sony IR codes
{
switch(results.value)
{
case PanasonicFour: pinOnTriple(1, 0, 0);
irsend.sendPanasonic(PanasonicAddress,PanasonicFour); // This should turn your TV on and off
break; // 2
case PanasonicTwo: pinOnTriple(0, 1, 0);
irsend.sendPanasonic(PanasonicAddress,PanasonicTwo);
break; // 3
case PanasonicFive: pinOnTriple(HIGH, LOW, HIGH);
irsend.sendPanasonic(PanasonicAddress,PanasonicFive);
break; // 5
case PanasonicSix: pinOnTriple(HIGH, HIGH, LOW);
irsend.sendPanasonic(PanasonicAddress,PanasonicSix);
break; // 6
case PanasonicSeven: pinOnTriple(HIGH, HIGH, HIGH);
irsend.sendPanasonic(PanasonicAddress,PanasonicSeven);
break; // 7
case PanasonicZero: pinOnTriple(LOW, LOW, LOW);
irsend.sendPanasonic(PanasonicAddress,PanasonicZero);
break; // 8
case PanasonicOne: pinOnTriple(LOW, LOW, HIGH);
irsend.sendPanasonic(PanasonicAddress,PanasonicOne);
break; // 9
case PanasonicThree: pinOnTriple(LOW, HIGH, HIGH);
irsend.sendPanasonic(PanasonicAddress,PanasonicThree);
break; // 10
case 0x100BCBD: pinOnTriple(LOW, LOW, LOW);
irsend.sendPanasonic(PanasonicAddress,PanasonicPower); // This should turn your TV on and off
irsend.sendJVC(JVCPower, 16,0); // hex value, 16 bits, no repeat
delay(50); // see http://www.sbprojects.com/knowledge/ir/jvc.php for information
irsend.sendJVC(JVCPower, 16,1); // hex value, 16 bits, repeat
delay(50);
break;
case 0x1004C4D:
irsend.sendPanasonic(PanasonicAddress,PMute);
break; // 11
case 0x1002C2D:
irsend.sendPanasonic(PanasonicAddress,PCPlus);
break; // 11
case 0x100ACAD:
irsend.sendPanasonic(PanasonicAddress,PCMinus);
break; // 11
case 0x1008485:
irsend.sendPanasonic(PanasonicAddress,PVMinus);
break; // 11
case 0x1000405:
irsend.sendPanasonic(PanasonicAddress,PVPlus);
break; // 11
case 0x100ECED:
irsend.sendPanasonic(PanasonicAddress,PRTune);
break; // 11
}
}
void pinOnTriple(int pin, int pino, int pini) // turns on digital pins for 1 second
{
digitalWrite(11, pin);
digitalWrite(12, pino);
digitalWrite(13, pini);
delay(1000);
digitalWrite(11, 0);
digitalWrite(12, 0);
digitalWrite(13, 0);
}
You should just check for receiving the repeat codes (0xFFFFFF) and just ignore this code. And just issue the resume command just once. You may be accidently skipping the valid codes.
Also, you need to issue a resume after transmitting IR (as tx disables rx).
This last one is probably the issue for you.
Hope it helps
may be worth putting in a delay before re-tx as the tx may overlap the repeat codes
For anyone interested in IR protocols - we have just launched a project for AnalysIR - IR Decoder & Analyzer GUI (Arduino & Raspberry Pi). Currently we support 17 IR protocols and are looking for more to add as part of the campaign. Suggestions Welcome!
If the project is successful, we hope to add support for Raspberry Pi !
You can find out more and support the Project by visiting http://igg.me/at/AnalysIR/x/3752156 or Screenshot via www.AnalysIR.com

Resources