View Single Post
  #5   Spotlight this post!  
Unread 02-02-2017, 22:13
elijah1111's Avatar
elijah1111 elijah1111 is offline
Registered User
FRC #4601 (Circuit Birds)
Team Role: Programmer
 
Join Date: Jan 2017
Rookie Year: 2015
Location: Ohio
Posts: 15
elijah1111 is an unknown quantity at this point
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
}
Reply With Quote