|
Re: Arduino with Robot-Open programming help
this is our current code, we are trying to hook it up to one of the digital ports on the side car itself instead on directly to the arduino robot shield
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <EEPROM.h>
#include <RobotOpen.h>
/* I/O Setup */
ROJoystick usb1(1); // Joystick #1
ROPWM leftmotorone(1);
ROPWM rightmotorone(0);
ROPWM leftmotortwo(2);
ROPWM rightmotortwo(3);
void setup()
{
/* Initiate comms */
RobotOpen.begin(&enabled, &disabled, &timedtasks);
pinMode(SIDECAR_DIGITAL7, OUTPUT);
}
/* This is your primary robot loop - all of your code
* should live here that allows the robot to operate
*/
void enabled() {
// Constantly update PWM values with joystick values
// Analog sticks feed back values from 0-255
// 255 - usb1.leftY() to invert a drive
leftmotorone.write(255 - usb1.leftY());
rightmotorone.write(usb1.rightY());
leftmotortwo.write(255 - usb1.leftY());
rightmotortwo.write(usb1.rightY());
if (usb1.btnA(1))
digitalWrite(SIDECAR_DIGITAL7, HIGH);
else
digitalWrite(SIDECAR_DIGITAL7, LOW);
}
/* This is called while the robot is disabled
* PWMs and Solenoids are automatically disabled
*/
void disabled() {
// safety code
}
/* This loop ALWAYS runs - only place code here that can run during a disabled state
* This is also a good spot to put driver station publish code
*/
void timedtasks() {
RODashboard.publish("Uptime Seconds", ROStatus.uptimeSeconds());
}
// !!! DO NOT MODIFY !!!
void loop() {
RobotOpen.syncDS();
}
|