arduino-uno


Every function executes on Arduino reset


I'm trying to control my home television through android mobile. I took the IR NEC code from the remote through an RF receiver. After that I interfaced Arduino with a WiFi module and IR transmitter. This lets me control my television via WiFi. But the thing is, whenever I reset the Arduino board, all the functions are occurring automatically: power on, channel increase and decrease, volume increase and decrease, and power off. After that, though, I can control it through android mobile and everything will work as intended. But this repeats again when I reset Arduino board. What could be causing this?
I'm attaching the code here:
#include<IRremote.h>
IRsend ir;
char serialA;
void setup()
{
pinMode(3, OUTPUT);
Serial.begin(115200); //baud rate - make sure it matches that of the module you got:
Serial.println("AT");
delay(1000);
Serial.println("AT+CIPMUX=1\r\n");
delay(1000);
Serial.println("AT+CIPSERVER=1,80\r\n");
delay(1000);
}
void loop()
{
if (Serial.available()>0 )
{
serialA = Serial.read();
IRREMOTE();
}
}
void IRREMOTE()
{
switch (serialA)
{
case 'A': //Power
ir.sendNEC(0x2FD48B7,32);
delay(500);
break;
case 'B': // AV/TV
ir.sendNEC(0x2FD28D7,32);
delay(500);
break;
case 'C': // Mute
ir.sendNEC(0x2FD08F7,32);
delay(500);
break;
case 'D': // CH+
ir.sendNEC(0x2FDD827,32);
delay(500);
break;
case 'E': // CH-
ir.sendNEC(0x2FDF807,32);
delay(500);
break;
case 'F': // Vol+
ir.sendNEC(0x2FD58A7,32);
delay(500);
break;
case 'G': // Vol-
ir.sendNEC(0x2FD7887,32);
delay(500);
break;
case 'H':
// Menu
ir.sendNEC(0x2FD30CF,32);
delay(500);
break;
case 'I':
// Alt
ir.sendNEC(0x2FD708F,32);
delay(500);
break;
case 'J':
// Scan
ir.sendNEC(0x2FDDA25,32);
delay(500);
break;
}
}
and
#include<IRremote.h>
IRsend ir;
char serialA;
void setup()
{
pinMode(3, OUTPUT);
Serial.begin(115200); //baud rate - make sure it matches that of the module you got:
Serial.println("AT");
delay(1000);
Serial.println("AT+CIPMUX=1\r\n");
delay(1000);
Serial.println("AT+CIPSERVER=1,80\r\n");
delay(1000);
}
void loop()
{
if (Serial.available()>0 )
{
serialA = Serial.read();
IRREMOTE();
}
}
void IRREMOTE()
{
if(serialA == '$') //Power
{
ir.sendNEC(0x2FD48B7,32);
}
else if(serialA == 'b') // AV/TV
{
ir.sendNEC(0x2FD28D7,32);
}
else if(serialA == 'c') // Mute
{
ir.sendNEC(0x2FD08F7,32);
}
else if(serialA == 'd') // CH+
{
ir.sendNEC(0x2FDD827,32);
}
else if(serialA == 'e') // CH-
{
ir.sendNEC(0x2FDF807,32);
}
else if(serialA == 'f') // Vol+
{
ir.sendNEC(0x2FD58A7,32);
}
else if(serialA == 'g') // Vol-
{
ir.sendNEC(0x2FD7887,32);
}
else if(serialA == 'h') // Menu
{
ir.sendNEC(0x2FD30CF,32);
}
else if(serialA == 'i') // Alt
{
ir.sendNEC(0x2FD708F,32);
}
else if(serialA == 'j') // Scan
{
ir.sendNEC(0x2FDDA25,32);
}
}
Hayes commands being send to a serial device usually generate a response. For example, when you send that AT command, device listening for that command will respond "OK". Also, in certain scenarios, what you write to the device/serial line may get echoed back to your input handler (Serial.read())
so, in order to fix your issue, you should clear the input buffer completely after you send the last AT command.

Related Links

upload a programme to Arduino-uno gives error “could not find any usb device”
Arduino UNO(9600) with Wizfi250 cannot send data to Ubidots
How to wire a 12V double solenoid to an Arduino?
Receiving data automatically in wifi(ESP8266) Even though connected my mobile with ESP8266
How to copy string (char*) from Flash to RAM with strcpy_P
LED's won't light up with Arduino
Every function executes on Arduino reset
What is the output of this arduino code?
Shield L6474 and motor equiped with a reducer
NRF24L01+PA+LNA (Transciever) not communicating between two arduinos
Can't program Arduino 328P after first time use of ICSP Sparkfun AVR Pocket Programmer
Arduino uploading issue: “avrdude: no programmer has been specified on the command line or the config file”
Code is showing multiple object declaration error during multiple file compilation
arduino wifi upload google spreadsheet
How to solve error compiling an arduino sketch?
load image in the TFT lcd screen without SD card

Categories

HOME
activiti
include
relay
bpmn
routes
cvs
jira
react-redux
malloc
callback
retrofit
dacpac
u-sql
windows-azure-storage
hex-editors
solaris-10
database-replication
code-review
google-cloud-speech
nodatime
lldb
predix
microsoft-r
facebook-access-token
intel-pin
kannel
social-media
minitab
maquette
file-rename
unboundid
media-queries
force-layout
android-ble
space-complexity
mixture-model
abstract-class
reportbuilder
impersonation
leading-zero
lumberjack
dism
google-closure
keydown
modelmapper
eclipse-gef
skeleton-css-boilerplate
outlook-2013
youcompleteme
hibernate-tools
winscp-net
powercli
colorama
windows-mobile-6.5
pintos
httplistener
transmitfile
google-web-starter-kit
superstack
whois
wso2cloud
execute
fouc
coveralls
varargs
embedded-code
appfabric-cache
sankey-diagram
coldbox
device-manager
markers
issuu
neolane
p4java
undefined-reference
intentservice
tidy
gridcontrol
eventlistener
drools-planner
bubble-chart
spyware
genshi
table-footer
telerik-scheduler
zend-translate
thunderbird-lightning
brewmp
anti-piracy
3gp

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App