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

ESP8266 AT response is OK But Cannot Reset it
How do I make two servo's move in opposite directions?
Sparkfun CAN BUS sheild with arduino UNO
Using Arduino and Motor Shield
AT+CSQ? returns error
Array accessing in arduino and for loop
Bluetooth module won't function when working with leapmotion
switch on or off the motor based on the reply of the user
IS my Modulo usage incorrect? What can
Use analog output as digital in relay pins
Arduino Uno and ESP8266-01
Power supply for raspberry and arduino
Arduino UNO and MPU 6050
Understanding timer choices/options
Programming attiny45 chip and ir remote library
Arduino Uno: Running multiple servos

Categories

HOME
java
bluetooth
webpack
stock
mean-stack
sqlite-net-extensions
jira
spring-jdbc
amortized-analysis
survey
win32gui
azure-media-services
azure-storage-tables
collectd
fortumo
fallback
designer
solaris-10
firefox-webextensions
scichart
introduction
immutable.js
object-detection
css-animations
realex-payments-api
devops
php-openssl
info.plist
publish
elasticsearch-ruby
srcset
r-raster
ecto
kendo-ui-grid
gammu
y86
fusionpbx
bower-install
vxworks
x11-forwarding
serverside-rendering
withings
lumberjack
preconditions
android-mediaprojection
fakeiteasy
vao
apple-news
menuitem
user-accounts
dotcover
smartcontracts
ionicons
jlink
rdfs
akka-cluster
pdfclown
migradoc
jquery-filter
removechild
mongocsharpdriver
nsviewcontroller
testng-dataprovider
historian
wso2cloud
icu4j
cyclomatic-complexity
deis
sysinternals
apache-commons-fileupload
sortedlist
jscript.net
googlemock
article
jubula
android-2.2-froyo
srs
imdbpy
industrial
quantlib-swig
jsctypes
listings
gridcontrol
dataadapter
mylyn
xamlparseexception
jelly
cisco-jtapi
dsn
netbeans-6.9
pendrive
work-stealing
boost-filesystem
mod-auth
infobox
xmlspy
appendto
ecl
lang
w3wp.exe
user-friendly
ti-dsp
sustainable-pace
private-members
document-conversion

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App