Go to Post If you have a robot you don't need any more, use it for demos, or let a rookie team borrow it to learn wiring, programming, and demo around their school. - Barry Bonzack [more]
Home
Go Back   Chief Delphi > Technical > Control System
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 13-04-2014, 10:51
tanguma26 tanguma26 is offline
Registered User
FRC #3999
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Killeen
Posts: 48
tanguma26 is an unknown quantity at this point
Arduino and FRC

Hello a friend of mine and myself have been working with the arduino and the system 221 designed to use the arduino for replacement of the C-rio. Anyone has experience programming for this system or program examples for a simple tank drive?
We are trying to introduces robotics were my friend lives which is a small town in Florida and we would like to have it ready for a science fair in the fall.

I made a program and if anyone could help me to check it would be helpful Thank you.

#include <SPI.h>
#include <SD.h>
#include <Ethernet.h>
#include <Servo.h>
#include <EEPROM.h>
#include <RobotOpen.h>



/* I/O Setup */
ROJoystick usb1(1); // Joystick #1




ROPWM leftDrive(0);
ROPWM rightDrive(1);
ROPWM motor1 (2);
ROPWM motor2 (3);
ROPWM motor3 (4);
ROPWM motor4 (5);


void setup()
{
/* Initiate comms */
RobotOpen.begin(&enabled, &disabled, &timedtasks);

//Configure Ditigal I/O
pinMode(SIDECAR_DIGITAL1, OUTPUT);
pinMode(SIDECAR_DIGITAL2, OUTPUT);
pinMode(SIDECAR_DIGITAL3, OUTPUT);
pinMode(SIDECAR_DIGITAL4, 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
// This contains all the motors operated by the Aurduino
leftDrive.write(usb1.leftY());
rightDrive.write(usb1.rightY());
motor1.write(usb1.btnX());
motor2.write(usb1.btnB());
motor3.write(usb1.dPadUp());
motor4.write(usb1.btnLShoulder());


// This contains all the DIO, most are spikes or relays.
if (usb1.btnA())
digitalWrite(SIDECAR_DIGITAL1, HIGH);
else
digitalWrite(SIDECAR_DIGITAL1, LOW);

if (usb1.btnStart())
digitalWrite(SIDECAR_DIGITAL2, HIGH);
else
digitalWrite(SIDECAR_DIGITAL2, LOW);

if (usb1.dPadLeft())
digitalWrite(SIDECAR_DIGITAL3, HIGH);
else
digitalWrite(SIDECAR_DIGITAL3, LOW);

if (usb1.dPadRight())
digitalWrite(SIDECAR_DIGITAL4, HIGH);
else
digitalWrite(SIDECAR_DIGITAL4, LOW);










}


/* This is called while the robot is disabled
* All outputs are automatically disabled (PWM, Solenoid, Digital Outs)
*/
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());
// RODashboard.publish("Analog0", analogZero.read()); // Display on dashboard
//RODashboard.debug("voltage1"); //Arduino Reading
//RODashboard.debug("voltage1");//Power board reading
//int sensorValue = analogZero.read();
//float voltage1 = sensorValue * (5.0 / 1023); // Volatge convertion from Arduino
//float voltage2 = voltage1 * (12.0 / 5.0);// Coming from power board


}


// !!! DO NOT MODIFY !!!
void loop() {
RobotOpen.syncDS();
}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:07.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi