Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // =======================================================================================
- // /////////////////////////Padawan Body Code ////////////////////////////////////////////
- // =======================================================================================
- // danf
- // Revised Date: 01/01/14 (unofficial revision by PaulM)
- // Designed to be used with a second Arduino running the Padawan Dome code
- // EasyTransfer and PS2X_lib libraries by Bill Porter
- //
- // PaulM's tweaks need latest Sabertooth and MP3Trigger libraries from:
- // - https://www.dimensionengineering.com/info/arduino
- // - https://github.com/sansumbrella/MP3Trigger-for-Arduino
- //
- // Set Sabertooth 2x25 Dip Switches 1 and 2 Down, All Others Up
- // For SyRen packetized Serial Set Switches 1 and 2 Down, All Others Up
- // For SyRen Simple Serial Set Switchs 2 & 4 Down, All Others Up
- // Placed a 10K ohm resistor between S1 & GND on the SyRen 10 itself
- //
- // (if using Lithium batteries set switch 3 Down on SyRen & Sabertooth 2x25)
- //
- // Arduino Pins: BotBoarduino Pins:
- // D01 = MP3 Trigger RX* D01 = MP3 Trigger RX*
- // D05 = Syren10 S1** D06 = PS2 DAT
- // D06 = Sabertooth S2*** D07 = PS2 COM
- // D07 = Sabertooth S1 D08 = PS2 ATT
- // D08 = Dome RXI D09 = PS2 CLK
- // D10 = PS2 ATT D10 = Dome RXI
- // D11 = PS2 COM D11 = Syren10 S1**
- // D12 = PS2 DAT D12 = Sabertooth S2***
- // D13 = PS2 CLK D13 = Sabertooth S1
- // A4 = LCD DAT A4 = LCD DAT
- // A5 = LCD CLK A5 = LCD CLK
- // D05 = used by internal speaker
- // *If using MP3 Trigger in mode 1, connect MP3 Trigger RX to D03 instead
- // **If using SyRen in mode 3, connect Syren S1 to D01 instead
- // ***S2 is not needed for Sabertooth's serial mode
- //
- // Extra sounds triggered by R2 + Square=54 Circle=55 X=56 Triangle=57
- //
- // This program is free software: you can redistribute it and/or modify it .
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- //
- //************************** Set speed and turn here************************************//
- #define drivespeed1 75 //set these 3 to whatever speeds work for you. 0=stop, 127=full speed.
- #define drivespeed2 100 //Recommend beginner: 50 to 75, experienced: 100 to 127, I like 100.
- #define drivespeed3 127 //Set to 0 if you only want 2 speeds.
- #define turnspeed 50 // the higher this number the faster it will spin in place, lower - easier to controll.
- // Recommend beginner: 40 to 50, experienced: 50 $ up, I like 75
- #define domespeed 110 // If using a speed controller for the dome, sets the top speed
- // Use a number up to 127 for serial
- #define ramping 5 // Ramping- the lower this number the longer R2 will take to speedup or slow down,
- // change this by incriments of 1
- #define MP3TRIGMODE 1 // 0 for regular mode (MP3 Tirgger RX connects to Pin 1)
- // 1 for Software Serial mode (MP3 Trigger connects to Pin 3)
- #define SYRENMODE 3 // 1=Simple Serial , 2=Packetized Software Serial (recommended), 3=Packetized Hardware Serial (S1 connects to Pin 1)
- // Do not use Simple Serial mode in close contact with people.
- // NOTE : you can't use MP3TRIGMODE 0 with SYRENMODE 3, since they both use Arduino Pin 1
- #define domecompensation 0 // For controllers that centering problems, causing slight dome drift in one direction
- #define drivecompensation 0 // use the lowest number with no drift
- // (this sets the Sabertooth's Deadband and will persist between restarts)
- // Motor powers in the range [-deadband, deadband] will be considered in the deadband,
- // and will not prevent the driver from entering nor cause the driver to leave an idle brake state.
- // 0 resets to the default, which is 3. valid setting is 0 to 127.
- #define domeBaudeRate 9600 // Set the baude rate for the Syren motor controller
- // for packetized options are: 2400, 9600, 19200 and 38400
- // for simple use 9600
- #define VOLJUMP 2 // Speed at which volume is adjusted (1=slowest 5=fast)
- #define VOLLIMIT 100 // Quietest volume can be set to (0-255, higher=quieter, over 64 is pretty quiet)
- #define LCD 0 // Connect to LCD via i2c (pins A4 & A5), default address #0 (A0-A2 not jumpered)
- // Backlight can be toggled on/off using R1 + Pad Left
- // (comment out if no LCD is connected)
- //Dome Automation Settings...
- #define AUTOMIN 5 // Minimum seconds between sounds in auto mode
- #define AUTOMAX 20 // Maximum seconds between sounds in auto mode
- //auto dome speeds, were -49 and 45, should be equal if using domegears
- #define DOMESPEEDL -30 // Speed that the dome will automatically spin left (negative)
- #define DOMESPEEDR 30 // Speed that the dome will automatically spin right (negative)
- #define ATTEMPTS 25 // How many times to try and connect to the PS2 controller
- #define BOARDTYPE 1 // 0 for regular Arduino, 1 for BotBoarduino (uses different PS2, ST & dome pins)
- byte drivespeed = drivespeed1;
- ///////include libs and declare variables////////////////////////////
- #include <Sabertooth.h>
- /*#if (SYRENMODE==3)
- Sabertooth SyR(128);
- #endif*/
- #include <SoftwareSerial.h>
- #if (SYRENMODE==1)
- #include <SyRenSimplified.h>
- #endif
- #include <SyRenSimplified.h>
- #include <PS2X_lib.h> //for v1.7
- #include <Servo.h>
- #include <MP3Trigger.h>
- #include <SoftEasyTransfer.h>
- #if defined(LCD)
- #include <Wire.h>
- #include <LiquidTWI.h> //this is the speedy i2C LCD library - get it here: http://forums.adafruit.com/viewtopic.php?f=19&t=21586
- LiquidTWI lcd(LCD);
- #endif
- #if (MP3TRIGMODE==1)
- SoftwareSerial trigSerial = SoftwareSerial(2, 3);
- #endif
- MP3Trigger trigger;
- #if (SYRENMODE==3)
- Sabertooth SyR(128);
- #endif
- #if (BOARDTYPE==0)
- #if (SYRENMODE<3)
- SoftwareSerial SyRSerial(2, 5);
- #endif
- SoftwareSerial domeSerial(2, 8);
- SoftwareSerial STSerial(2, 7);
- #else
- #if (SYRENMODE<3)
- SoftwareSerial SyRSerial(2, 11);
- #endif
- SoftwareSerial domeSerial(2, 10);
- SoftwareSerial STSerial(2, 13);
- #endif
- Sabertooth ST(128, STSerial);
- #if (SYRENMODE==1)
- SyRenSimplified SyR(SyRSerial); // Use SWSerial as the serial port.
- #elif (SYRENMODE==2)
- Sabertooth SyR(128, SyRSerial);
- #endif
- SoftEasyTransfer ET;//create object
- struct SEND_DATA_STRUCTURE{
- //put your variable definitions here for the data you want to send
- //THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
- int hpx; // hp movement
- int hpy; // hp movement
- int hpl; // hp light
- int hpa; // hp automation
- int dsp; // 100=no change, 0=random, 1=alarm, 4=whistle, 5=leia, 6=short circut, 10=EQ, 11=alarm2,
- }; // 21=speed1, 22=speed2, 23=speed3, 24=logics+, 25=logics-
- SEND_DATA_STRUCTURE domeData;//give a name to the group of data
- PS2X ps2x; // create PS2 Controller Class
- int error = 0; // part of the ps2x lib
- //byte type = 0; // part of the ps2x lib
- //byte vibrate = 0; // part of the ps2x lib
- byte vol = 50; // 0 = full volume, 255 off
- byte drive = 0; // 0 = drive motors off ( right stick disabled )
- byte automate = 0;
- unsigned long automateMillis = 0;
- byte automateDelay = random(AUTOMIN,AUTOMAX);// set this to min and max seconds between sounds
- int turnDirection = 0;
- byte action = 0;
- unsigned long DriveMillis = 0;
- int drivenum = 0;
- int sticknum = 0;
- int domenum = 0;
- int turnnum = 0;
- #if defined(LCD)
- byte lcdlight = 0; //used to toggle the LCD backlight on and off
- #endif
- //////////////set up run once//////////////////////////////////////////
- void setup(){
- #if defined(LCD)
- lcd.begin(16, 2);// sets up the LCD's number of rows and columns
- lcd.clear();
- lcd.setBacklight(HIGH);
- delay(50);
- lcd.print("Starting"); // Print a message to the LCD.
- lcd.setCursor(12,0); lcd.print(String(memoryFree()));
- delay(500);
- #endif
- #if(SYRENMODE<3)
- SyRSerial.begin(domeBaudeRate);
- #endif
- #if(SYRENMODE==1)
- SyR.motor(0);
- #elif(SYRENMODE==2)
- SyR.autobaud();
- #elif(SYRENMODE==3)
- SabertoothTXPinSerial.begin(domeBaudeRate);
- SyR.autobaud();
- #endif
- STSerial.begin(9600); // 9600 is the default baud rate for Sabertooth packet serial.
- ST.autobaud(); // Send the autobaud command to the Sabertooth controller(s).
- // NOTE: *Not all* Sabertooth controllers need this command.
- // It doesn't hurt anything, but V2 controllers use an
- // EEPROM setting (changeable with the function setBaudRate) to set
- // the baud rate instead of detecting with autobaud.
- //
- // If you have a 2x12, 2x25 V2, 2x60 or SyRen 50, you can remove
- // the autobaud line and save yourself two seconds of startup delay.
- ST.setTimeout(950);
- #if !defined(SYRENSIMPLE)
- SyR.setTimeout(950);
- #endif
- ST.setDeadband(drivecompensation);
- ST.drive(0); // The Sabertooth won't act on mixed mode packet serial commands until
- ST.turn(0); // it has received power levels for BOTH throttle and turning, since it
- // mixes the two together to get diff-drive power levels for both motors.
- #if (MP3TRIGMODE==1)
- trigger.setup(&trigSerial);
- trigSerial.begin( MP3Trigger::serialRate() );
- #else
- trigger.setup(&Serial);
- #endif
- byte attempts=0;
- #if defined(LCD)
- lcd.clear();
- lcd.print("PS2...");
- lcd.setCursor(12,0); lcd.print(String(memoryFree()));
- delay(500);
- #endif
- trigger.setVolume(80); //set volume low for now
- while(attempts<ATTEMPTS) { //loop around until a PS2 controller is found or we've attempted too many times
- //lcd.setCursor(12,0); lcd.print(String(memoryFree()));
- #if (BOARDTYPE==0)
- error = ps2x.config_gamepad(13,11,10,12, false, false); //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
- #else
- error = ps2x.config_gamepad(9,7,8,6, false, false); //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
- #endif
- lcd.setCursor(12,0); lcd.print(String(memoryFree())); delay(500);
- if((error==0)||(error==3)) attempts=ATTEMPTS; //PS2 controller was found, or found with pressure disabled so we'll get out of this WHILE loop
- #if defined(LCD)
- lcd.setCursor(12,1); lcd.print(String(attempts)+" ");
- lcd.setCursor(0, 1);
- if(error == 0){
- lcd.print("found "); //found a PS2 controller
- playSound(52);
- }
- else if(error == 1) {
- lcd.print("unfound"); //not found!
- //playSound(53);
- }
- else if(error == 2) {
- lcd.print("no cmds"); //found but not accepting commands
- //playSound(53);
- }
- else if(error == 3) {
- lcd.print("no pres"); //found but pressure not enabled
- playSound(52);
- }
- #endif
- delay(100);
- attempts++;
- }
- trigger.setVolume(vol);//set volume back to default value
- //type = ps2x.readType();
- domeSerial.begin(57600);//start the library, pass in the data details and the name of the serial port.
- ET.begin(details(domeData), &domeSerial);
- #if defined(LCD)
- lcd.clear();
- //lcd.print("PADAWAN"); // Print a message to the LCD.
- //delay(100);
- lcd.setBacklight(LOW);
- #endif
- playSound(52); //play a sound to test things
- }
- // variables created by the build process when compiling the sketch (used for the memoryFree function)
- extern int __bss_end;
- extern void *__brkval;
- // function to return the amount of free RAM
- int memoryFree() {
- int freeValue;
- if((int)__brkval == 0) freeValue = ((int)&freeValue) - ((int)&__bss_end);
- else freeValue = ((int)&freeValue) - ((int)__brkval);
- return freeValue;
- }
- ///////function to play sound (also outputs to LCD if connected)////////////////
- void playSound(int soundNumber) {
- #if defined(LCD)
- lcd.setCursor(0, 0);
- lcd.print("Snd"+String(soundNumber)+" ");
- #endif
- trigger.play(soundNumber);
- }
- ////////////////////////////////////////////////////////////////////////////////////////////
- ///////Loop run over and over//////////////////////////////////////
- //////////////////////////////////////////////////////////////////
- void loop(){
- if(error == 1) //skip loop if no controller found
- return;
- if(ps2x.Analog(PSS_RX) ==255 && ps2x.Analog(PSS_RY) ==255 && ps2x.Analog(PSS_LX)==255 &&ps2x.Analog(PSS_LY)==255)
- {
- ST.drive(0);
- ST.turn(0);
- SyR.motor(1,0);
- return;
- }
- ps2x.read_gamepad(); //read controller and set large motor to spin at 'vibrate' speed
- //// enable / disable right stick & play sound
- if(ps2x.ButtonPressed(PSB_START))
- {if (drive<1)
- {
- #if defined(LCD)
- lcd.setCursor(0, 1);
- lcd.print("-Drive Enabled-");
- #endif
- drive = 1; playSound(52);}
- else {
- #if defined(LCD)
- lcd.setCursor(0, 1);
- lcd.print("-Drive Disabled-");
- #endif
- drive = 0; playSound(53);}
- }
- ////turn hp automation or automate on & off
- if(ps2x.ButtonPressed(PSB_SELECT))
- {if(ps2x.Button(PSB_R2))
- {if(domeData.hpa == 1)
- {
- #if defined(LCD)
- lcd.setCursor(0, 1);
- lcd.print(" -Auto HP OFF- ");
- #endif
- domeData.hpa = 0; domeData.dsp = 100; ET.sendData();}//if hp automation is off, turn it on
- else
- {
- #if defined(LCD)
- lcd.setCursor(0, 1);
- lcd.print(" -Auto HP ON- ");
- #endif
- domeData.hpa = 1; domeData.dsp = 100; ET.sendData();}//turn hp automation off
- }
- else
- { if (automate<1) {
- #if defined(LCD)
- lcd.setCursor(0, 1);
- lcd.print(" -Automate ON- ");
- #endif
- automate = 1;
- playSound(52);
- }
- else {
- #if defined(LCD)
- lcd.setCursor(0, 1);
- lcd.print(" -Automate OFF- ");
- #endif
- automate = 0; action = 0; playSound(53);}
- }}
- /////////////automate
- if (automate == 1)
- { if (ps2x.Analog(PSS_LX)!=128)
- { automateMillis = millis();}
- unsigned long currentMillis = millis();
- if (currentMillis - automateMillis > (automateDelay*1000))
- {
- automateMillis = millis();
- action = random(1,5);
- if (action>1)
- {
- (playSound(random(32,52)));
- }
- if (action<4)
- {
- #if (SYRENMODE==1)
- SyR.motor(turnDirection);
- #elif(SYRENMODE>=2)
- SyR.motor(1,turnDirection);
- #endif
- delay(750);
- #if(SYRENMODE==1)
- SyR.motor(0);
- #elif(SYRENMODE>=2)
- SyR.motor(1,0);
- #endif
- if (turnDirection>0)
- {turnDirection = DOMESPEEDL;}
- else
- {turnDirection = DOMESPEEDR;}
- }
- automateDelay = random(AUTOMIN,AUTOMAX);// set this to min and max seconds between sounds
- }}
- ////volume controll
- if(ps2x.Button(PSB_PAD_UP))
- {
- if(ps2x.Button(PSB_R1))
- { if (vol>0)
- {
- vol=vol-VOLJUMP;
- if(vol<0) vol=0;
- #if defined(LCD)
- lcd.setCursor(9, 0);
- lcd.print("Vol "+String(vol)+" ");
- #endif
- trigger.setVolume(vol);}// volume up
- }
- }
- if(ps2x.Button(PSB_PAD_DOWN))
- {
- if(ps2x.Button(PSB_R1))
- { if (vol<VOLLIMIT)
- {
- vol=vol+VOLJUMP;
- if(vol>VOLLIMIT) vol=VOLLIMIT;
- #if defined(LCD)
- lcd.setCursor(9, 0);
- lcd.print("Vol "+String(vol)+" ");
- #endif
- trigger.setVolume(vol);}//volume down
- }
- }
- ////LCD backlight toggle on/off
- #if defined(LCD)
- if(ps2x.Button(PSB_PAD_LEFT))
- {
- if(ps2x.Button(PSB_R1))
- {
- if (lcdlight==0)
- { //turn on backlight
- lcd.setBacklight(HIGH);
- lcdlight=1;
- }
- else
- { //turn off backlight
- lcd.setBacklight(LOW);
- lcdlight=0;
- }
- }
- }
- #endif
- ////Logic display brightness
- if(ps2x.ButtonPressed(PSB_PAD_UP))
- {
- if(ps2x.Button(PSB_L1))
- {
- domeData.dsp = 24; ET.sendData();
- }
- }
- if(ps2x.ButtonPressed(PSB_PAD_DOWN))
- {
- if(ps2x.Button(PSB_L1))
- {
- domeData.dsp = 25; ET.sendData();
- }
- }
- /////hp movement
- if(ps2x.ButtonPressed(PSB_PAD_UP))
- {if (!((ps2x.Button(PSB_R1))||(ps2x.Button(PSB_L1))))
- {
- domeData.hpy = 30; domeData.dsp = 100; ET.sendData();
- }}
- if(ps2x.ButtonPressed(PSB_PAD_DOWN))
- {if (!((ps2x.Button(PSB_R1))||(ps2x.Button(PSB_L1))))
- {
- domeData.hpy = 150; domeData.dsp = 100; ET.sendData();
- }}
- if(ps2x.ButtonReleased(PSB_PAD_UP)||ps2x.ButtonReleased(PSB_PAD_DOWN))
- {domeData.hpy = 0; domeData.dsp = 100; ET.sendData();}
- if(ps2x.ButtonPressed(PSB_PAD_RIGHT))
- {
- domeData.hpx = 150; domeData.dsp = 100; ET.sendData();
- }
- if(ps2x.ButtonPressed(PSB_PAD_LEFT))
- {
- domeData.hpx = 30; domeData.dsp = 100; ET.sendData();
- }
- if(ps2x.ButtonReleased(PSB_PAD_RIGHT)||ps2x.ButtonReleased(PSB_PAD_LEFT))
- {domeData.hpx = 0; domeData.dsp = 100; ET.sendData();}
- /////play sounds and change display
- if(ps2x.ButtonPressed(PSB_GREEN))//triangle top
- {if(ps2x.Button(PSB_L1))
- {(playSound(8)); domeData.dsp = 0; ET.sendData();}
- else if(ps2x.Button(PSB_L2))
- {(playSound(2)); domeData.dsp = 0; ET.sendData();}
- else if(ps2x.Button(PSB_R1))
- {(playSound(9)); domeData.dsp = 0; ET.sendData();}
- else if(ps2x.Button(PSB_R2))
- { // PLAY EXTRA/CUSTOM SOUND FILE
- (playSound(57)); domeData.dsp = 0; ET.sendData();}
- else
- {(playSound(random(13,17))); domeData.dsp = 0; ET.sendData();}}
- if(ps2x.ButtonPressed(PSB_BLUE))//x bottom
- {if(ps2x.Button(PSB_L1))
- {(playSound(6)); domeData.dsp = 6; ET.sendData();}
- else if(ps2x.Button(PSB_L2))
- {(playSound(1)); domeData.dsp = 1; ET.sendData(); domeData.dsp = 0;}
- else if(ps2x.Button(PSB_R1))
- {(playSound(11)); domeData.dsp = 11; ET.sendData(); domeData.dsp = 0;}
- else if(ps2x.Button(PSB_R2))
- { // PLAY EXTRA/CUSTOM SOUND FILE
- (playSound(random(56,65))); domeData.dsp = 0; ET.sendData();} // random lemur sound (total of 9)
- else
- {(playSound(random(17,25))); domeData.dsp = 0; ET.sendData();}}
- if(ps2x.ButtonPressed(PSB_RED))//circle right
- {if(ps2x.Button(PSB_L1))
- {(playSound(7)); domeData.dsp = 0; ET.sendData();}
- else if(ps2x.Button(PSB_L2))
- {(playSound(3)); domeData.dsp = 0; ET.sendData();}
- else if(ps2x.Button(PSB_R1))
- {(playSound(10)); domeData.dsp = 10; ET.sendData();}
- else if(ps2x.Button(PSB_R2))
- { // PLAY EXTRA/CUSTOM SOUND FILE
- (playSound(55)); domeData.dsp = 0; ET.sendData();}
- else
- {(playSound(random(32,52))); domeData.dsp = 0; ET.sendData();}}
- if(ps2x.ButtonPressed(PSB_PINK))//square left
- {if(ps2x.Button(PSB_L1))
- {(playSound(5)); domeData.dsp = 5; ET.sendData(); domeData.dsp = 0;}
- else if(ps2x.Button(PSB_L2))
- {(playSound(4)); domeData.dsp = 4; ET.sendData();}
- else if(ps2x.Button(PSB_R1))
- {(playSound(12)); domeData.dsp = 0; ET.sendData();}
- else if(ps2x.Button(PSB_R2))
- { // PLAY EXTRA/CUSTOM SOUND FILE
- (playSound(54)); domeData.dsp = 0; ET.sendData();}
- else
- {(playSound(random(25,32))); domeData.dsp = 0; ET.sendData();}}
- ////turn hp light on & off
- if(ps2x.ButtonPressed(PSB_L3)) //left joystick
- {
- if(domeData.hpl == 1)
- {domeData.hpl = 0; domeData.dsp = 100; ET.sendData();}//if hp light is on, turn it off
- else
- {domeData.hpl = 1; domeData.dsp = 100; ET.sendData();}//turn hp light on
- }
- ////Change drivespeed
- if(ps2x.ButtonPressed(PSB_R3)) //right joystick
- {
- if(drivespeed == drivespeed1)//if in lowest speed
- {
- #if defined(LCD)
- lcd.setCursor(0, 1); lcd.print("- Medium Speed -");
- #endif
- drivespeed = drivespeed2; playSound(53);domeData.dsp = 22; ET.sendData(); domeData.dsp = 0;}//change to medium speed and play sound 3-tone
- else if(drivespeed == drivespeed2 && (drivespeed3!=0))//if in medium speed
- {
- #if defined(LCD)
- lcd.setCursor(0, 1); lcd.print("- *HIGH SPEED* -");
- #endif
- drivespeed = drivespeed3; playSound(1);domeData.dsp = 23; ET.sendData(); domeData.dsp = 0;}//change to high speed and play sound scream
- else////////////////////////////////////////we must be in high speed
- {
- #if defined(LCD)
- lcd.setCursor(0, 1); lcd.print("- Slow Speed -");
- #endif
- drivespeed = drivespeed1; playSound(52);domeData.dsp = 21; ET.sendData(); domeData.dsp = 0;}//change to low speed and play sound 2-tone
- }
- /////foot drives
- /////////////////new stuff//////////////////
- sticknum = (map(ps2x.Analog(PSS_RY), 0, 255, -drivespeed, drivespeed));
- if (drivenum < sticknum)
- {
- if (sticknum-drivenum<(ramping+1))
- drivenum+=ramping;
- else
- drivenum = sticknum;
- }
- else if (drivenum > sticknum)
- {
- if (drivenum-sticknum<(ramping+1))
- drivenum-=ramping;
- else
- drivenum = sticknum;
- }
- turnnum = (ps2x.Analog(PSS_RX));
- if (turnnum <= 200 && turnnum >= 54)
- turnnum = (map(ps2x.Analog(PSS_RX), 54, 200, -(turnspeed/3), (turnspeed/3)));
- else if (turnnum > 200)
- turnnum = (map(ps2x.Analog(PSS_RX), 201, 255, turnspeed/3, turnspeed));
- else if (turnnum < 54)
- turnnum = (map(ps2x.Analog(PSS_RX), 0, 53, -turnspeed, -(turnspeed/3)));
- //////////////////////////////////
- if (drive == 1)// right stick (drive)
- {
- ST.turn(turnnum);
- ST.drive(drivenum);
- }
- /////dome drive
- domenum = (map(ps2x.Analog(PSS_LX), 0, 255, -domespeed, domespeed));
- if (domenum > -domecompensation && domenum < domecompensation)
- domenum = 0;
- #if defined(LCD)
- lcd.setCursor(0, 1);
- lcd.print("Sy"+String(domenum)+" ");
- #endif
- #if(SYRENMODE==1)
- SyR.motor(domenum);
- #elif(SYRENMODE>=2)
- SyR.motor(1,domenum);
- #endif
- ////////////
- delay(50);
- }
- /////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement