ARDUINO DIY PROJECT CODE COMPATIBILITY

CAN I USE A CODE FOR ARDUINO UNO TO ARDUINO 101

THE CODE IS.........................

signed int x;
signed int y;
signed int z;
signed int btna;
signed int btnb;
float a;
float m;

String str;
char dir = 0;

int ML = 4;
int MR = 7;

int EL = 5;
int ER = 6;

int el = 0;
int er = 0;

int elp = 0;
int erp = 0;

boolean fast = true;
boolean StateA0 = false;
boolean StateA1 = false;
boolean State11 = false;

void setup() {

pinMode(MR, OUTPUT);
pinMode(ML, OUTPUT);
pinMode(ER, OUTPUT);
pinMode(EL, OUTPUT);

pinMode(11, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);

Serial.begin(9600);
Serial.println("Start");
}

void loop()
{
while(Serial.available())
{

char getData = Serial.read();

if (getData == 'M')
{
m = Serial.parseFloat();

if (Serial.read() == '#')
{
processM();
}
}

if (getData == 'A')
{
a = Serial.parseFloat();

if (Serial.read() == '#')
{
processA();
}
}

if (getData == 'a')
{
delay(5);
if (Serial.read() == '#')
{
processa();
}
}

if (getData == 'b')
{
delay(5);
if (Serial.read() == '#')
{
processb();
}
}

if (getData == 'c')
{
delay(5);
if (Serial.read() == '#')
{
processc();
}
}

if (getData == 'x')
{
delay(5);
if (Serial.read() == '#')
{
processx();
}
}

if (getData == 'y')
{
delay(5);
if (Serial.read() == '#')
{
processy();
}
}

if (getData == 'z')
{
delay(5);
if (Serial.read() == '#')
{
processz();
}
}

if (getData == '~') {

x = Serial.parseInt();

if (Serial.read() == '*') {

y = Serial.parseInt();

if (Serial.read() == '@') {

z = Serial.parseInt();

if (Serial.read() == '#') {

process();
}
}
}
}

}

}

void processa(){
Serial.println("Button a! ");
StateA0 = !StateA0;
if (StateA0 == true) { digitalWrite(A0, HIGH); } else { digitalWrite(A0, LOW); }
Serial.flush();
}

void processb(){
Serial.println("Button b! ");
State11 = !State11;
if (State11 == true) { digitalWrite(11, HIGH); } else { digitalWrite(11, LOW); }
Serial.flush();
}

void processc(){
Serial.println("Button c! ");
StateA1 = !StateA1;
if (StateA1 == true) { digitalWrite(A1, HIGH); } else { digitalWrite(A1, LOW); }
Serial.flush();
}

void processx(){
Serial.println("Button x! ");
Serial.flush();
fast = true;
}

void processy(){
Serial.println("Button y! ");
Serial.flush();
}

void processz(){
Serial.println("Button z! ");
Serial.flush();
fast = false;
}

void processM(){
// m1 = map(m, 0, 500, 0, 255);
// Serial.print("Received Magnitude: ");
// Serial.println(m1);
// Serial.flush();
}

void processA(){
Serial.print("Received Angle: ");
Serial.println(a);
Serial.flush();
}

void process(){

if (fast == false) { er = map(y, 0, 500, 0, 255); }
else { er = y; }

if (er < 0) {
digitalWrite(MR, HIGH);
}
else if (er >= 0) {
digitalWrite(MR, LOW);
}
erp = abs(er);

if (fast == false) { el = map(x, 0, 500, 0, 255); }
else { el = x; }

if (el < 0) {
digitalWrite(ML, HIGH);
}
else if (el >= 0) {
digitalWrite(ML, LOW);
}
elp = abs(el);

analogWrite(EL, elp);
analogWrite(ER, erp);

Serial.flush();
}

ArduinoRobotJoystick4WD.ino (4.04 KB)

I think you need to read this first.

:o :o Iam a fresher to ARDUINO
so i will take some time to get with ARDUINO.......... :confused: :confused: :confused:

Your sketch compiles fine here for a 101 so without any further information I would say yes it can be used on a 101