Skip to content

Instantly share code, notes, and snippets.

@todocono
Last active November 17, 2022 02:36
Show Gist options
  • Save todocono/23773ff4c4653df0ad710509fad10424 to your computer and use it in GitHub Desktop.
Save todocono/23773ff4c4653df0ad710509fad10424 to your computer and use it in GitHub Desktop.
/*
Based on ReceiveSingleValue by Oliver Steele, 2020-2022
See more at https://osteele.github.io/Arduino_SerialRecord/
Arduino code
Programmed in class - Interaction Lab 2022Fall
This example code is in the public domain.
*/
#include "SerialRecord.h"
#include <Servo.h>
SerialRecord reader(3);
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
int led1 = 13;
int led2 = 11;
void setup() {
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
reader.read();
digitalWrite(led1, reader[0]);
analogWrite(led2, reader[1]);
myservo.write(reader[2]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment