Upload files to "/"
This commit is contained in:
52
deej-5-sliders-vanilla.ino
Normal file
52
deej-5-sliders-vanilla.ino
Normal file
@@ -0,0 +1,52 @@
|
||||
const int NUM_SLIDERS = 5;
|
||||
const int analogInputs[NUM_SLIDERS] = {A0, A1, A2, A3, A7};
|
||||
|
||||
int analogSliderValues[NUM_SLIDERS];
|
||||
|
||||
void setup() {
|
||||
for (int i = 0; i < NUM_SLIDERS; i++) {
|
||||
pinMode(analogInputs[i], INPUT);
|
||||
}
|
||||
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
updateSliderValues();
|
||||
sendSliderValues(); // Actually send data (all the time)
|
||||
// printSliderValues(); // For debug
|
||||
delay(10);
|
||||
}
|
||||
|
||||
void updateSliderValues() {
|
||||
for (int i = 0; i < NUM_SLIDERS; i++) {
|
||||
analogSliderValues[i] = analogRead(analogInputs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void sendSliderValues() {
|
||||
String builtString = String("");
|
||||
|
||||
for (int i = 0; i < NUM_SLIDERS; i++) {
|
||||
builtString += String((int)analogSliderValues[i]);
|
||||
|
||||
if (i < NUM_SLIDERS - 1) {
|
||||
builtString += String("|");
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println(builtString);
|
||||
}
|
||||
|
||||
void printSliderValues() {
|
||||
for (int i = 0; i < NUM_SLIDERS; i++) {
|
||||
String printedString = String("Slider #") + String(i + 1) + String(": ") + String(analogSliderValues[i]) + String(" mV");
|
||||
Serial.write(printedString.c_str());
|
||||
|
||||
if (i < NUM_SLIDERS - 1) {
|
||||
Serial.write(" | ");
|
||||
} else {
|
||||
Serial.write("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user