|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Arduino Communication with Roborio
We have an arduino that runs the lights on our teams robot. We were wondering if there is a way to have the arduino react to commands made from the driver station. Thanks for any help you can provide.
|
|
#2
|
||||
|
||||
|
Re: Arduino Communication with Roborio
what do you mean by the driver station commands? what you could do you could use a pwm line or dio from the roborio to the ardouino and read it there
|
|
#3
|
|||
|
|||
|
Re: Arduino Communication with Roborio
You can have the Driver Station talk to the roboRIO, and then have the roboRIO talk to the Arduino using the serial port or I2C.
|
|
#4
|
||||
|
||||
|
Re: Arduino Communication with Roborio
How complicated of lighting are we talking here? Would a simple PWM line or DIO not suffice. Just have the roborio output a PWM wave to the arduino to read then you could have your various lighting settings based on the PWM signals.
|
|
#5
|
||||
|
||||
|
Re: Arduino Communication with Roborio
I would do something like this on arduino side, you could also have multiple pwm values for diffrent lights if you wanted it to.
Code:
float PWMsignal;//the signal from the roborio
void setup() {
// put your setup code here, to run once:
PWMsignal=0;//intilizes signal
Serial.begin(9600);//syncs up serial output
}
void loop() {
// put your main code here, to run repeatedly:
PWMsignal=analogRead(3);//reads the pwm value for pin 3
if(PWMsignal=42){//if its whatever pwm value you want turn pin 4 on
digitalWrite(4,HIGH);
}
else{
digitalWrite(4,LOW);
}
Serial.println(PWMsignal);//outputs value to serial port
}
|
|
#6
|
||||
|
||||
|
Re: Arduino Communication with Roborio
|
|
#7
|
||||
|
||||
|
Re: Arduino Communication with Roborio
indeedCode:
int PWMsignal; // ... if (PWMsignal == 42) // ... Another dead simple way would be to use some DIO as outputs. You can have 2^n modes where n is the number of outputs you use. From Easy to Hard (my opinion of course): DIO, UART, TCP/UDP, I2C Last edited by RyanN : 03-02-2017 at 11:08. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|