originally posted in editor section (srry)
a bit embarraced but i am no programer
i just got to arduino to make a human interface control device
any ways i am using an arduino pro mini connected to pc through a ttl usb
the board is connected to 8 toggle switches and 2 sliding potentiometers
i used https://create.arduino.cc/
giving code of
// Include Libraries
#include "Arduino.h"
#include "Potentiometer.h"
#include "Button.h"
// Pin Definitions
#define POTENTIOMETERSLIDE_5V1_1_PIN_WIPER A0
#define POTENTIOMETERSLIDE_5V2_2_PIN_WIPER A1
#define TOGGLESWITCH_1_PIN_2 2
#define TOGGLESWITCH_2_PIN_2 3
#define TOGGLESWITCH_3_PIN_2 4
#define TOGGLESWITCH_4_PIN_2 5
#define TOGGLESWITCH_5_PIN_2 6
#define TOGGLESWITCH_6_PIN_2 7
#define TOGGLESWITCH_7_PIN_2 8
#define TOGGLESWITCH_8_PIN_2 10
// Global variables and defines
// object initialization
Potentiometer potentiometerSlide_5v1_1(POTENTIOMETERSLIDE_5V1_1_PIN_WIPER);
Potentiometer potentiometerSlide_5v2_2(POTENTIOMETERSLIDE_5V2_2_PIN_WIPER);
Button ToggleSwitch_1(TOGGLESWITCH_1_PIN_2);
Button ToggleSwitch_2(TOGGLESWITCH_2_PIN_2);
Button ToggleSwitch_3(TOGGLESWITCH_3_PIN_2);
Button ToggleSwitch_4(TOGGLESWITCH_4_PIN_2);
Button ToggleSwitch_5(TOGGLESWITCH_5_PIN_2);
Button ToggleSwitch_6(TOGGLESWITCH_6_PIN_2);
Button ToggleSwitch_7(TOGGLESWITCH_7_PIN_2);
Button ToggleSwitch_8(TOGGLESWITCH_8_PIN_2);
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println("start");
ToggleSwitch_1.init();
ToggleSwitch_2.init();
ToggleSwitch_3.init();
ToggleSwitch_4.init();
ToggleSwitch_5.init();
ToggleSwitch_6.init();
ToggleSwitch_7.init();
ToggleSwitch_8.init();
menuOption = menu();
}
//
Main logic of your circuit. It defines the interaction between the
components you selected. After setup, it runs over and over again, in an
eternal loop.
void loop()
{
if(menuOption == '1') {
// Slide Pot - X-Large (10k Linear Taper) #1 - Test Code
int potentiometerSlide_5v1_1Val = potentiometerSlide_5v1_1.read();
Serial.print(F("Val: ")); Serial.println(potentiometerSlide_5v1_1Val);
}
else if(menuOption == '2') {
// Slide Pot - X-Large (10k Linear Taper) #2 - Test Code
int potentiometerSlide_5v2_2Val = potentiometerSlide_5v2_2.read();
Serial.print(F("Val: ")); Serial.println(potentiometerSlide_5v2_2Val);
}
else if(menuOption == '3') {
// ToggleSwitch #1 - Test Code
//read Toggle Switch state.
//if Switch is open function will return LOW (0).
//if it is closed function will return HIGH (1).
bool ToggleSwitch_1Val = ToggleSwitch_1.read();
Serial.print(F("Val: ")); Serial.println(ToggleSwitch_1Val);
}
else if(menuOption == '4') {
// ToggleSwitch #2 - Test Code
//read Toggle Switch state.
//if Switch is open function will return LOW (0).
//if it is closed function will return HIGH (1).
bool ToggleSwitch_2Val = ToggleSwitch_2.read();
Serial.print(F("Val: ")); Serial.println(ToggleSwitch_2Val);
}
else if(menuOption == '5') {
// ToggleSwitch #3 - Test Code
//read Toggle Switch state.
//if Switch is open function will return LOW (0).
//if it is closed function will return HIGH (1).
bool ToggleSwitch_3Val = ToggleSwitch_3.read();
Serial.print(F("Val: ")); Serial.println(ToggleSwitch_3Val);
}
else if(menuOption == '6') {
// ToggleSwitch #4 - Test Code
//read Toggle Switch state.
//if Switch is open function will return LOW (0).
//if it is closed function will return HIGH (1).
bool ToggleSwitch_4Val = ToggleSwitch_4.read();
Serial.print(F("Val: ")); Serial.println(ToggleSwitch_4Val);
}
else if(menuOption == '7') {
// ToggleSwitch #5 - Test Code
//read Toggle Switch state.
//if Switch is open function will return LOW (0).
//if it is closed function will return HIGH (1).
bool ToggleSwitch_5Val = ToggleSwitch_5.read();
Serial.print(F("Val: ")); Serial.println(ToggleSwitch_5Val);
}
else if(menuOption == '8') {
// ToggleSwitch #6 - Test Code
//read Toggle Switch state.
//if Switch is open function will return LOW (0).
//if it is closed function will return HIGH (1).
bool ToggleSwitch_6Val = ToggleSwitch_6.read();
Serial.print(F("Val: ")); Serial.println(ToggleSwitch_6Val);
}
else if(menuOption == '9') {
// ToggleSwitch #7 - Test Code
//read Toggle Switch state.
//if Switch is open function will return LOW (0).
//if it is closed function will return HIGH (1).
bool ToggleSwitch_7Val = ToggleSwitch_7.read();
Serial.print(F("Val: ")); Serial.println(ToggleSwitch_7Val);
}
else if(menuOption == '10') {
// ToggleSwitch #8 - Test Code
//read Toggle Switch state.
//if Switch is open function will return LOW (0).
//if it is closed function will return HIGH (1).
bool ToggleSwitch_8Val = ToggleSwitch_8.read();
Serial.print(F("Val: ")); Serial.println(ToggleSwitch_8Val);
}
if (millis() - time0 > timeout)
{
menuOption = menu();
}
}
// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{
Serial.println(F("\nWhich component would you like to test?"));
Serial.println(F("(1) Slide Pot - X-Large (10k Linear Taper) #1"));
Serial.println(F("(2) Slide Pot - X-Large (10k Linear Taper) #2"));
Serial.println(F("(3) ToggleSwitch #1"));
Serial.println(F("(4) ToggleSwitch #2"));
Serial.println(F("(5) ToggleSwitch #3"));
Serial.println(F("(6) ToggleSwitch #4"));
Serial.println(F("(7) ToggleSwitch #5"));
Serial.println(F("(8) ToggleSwitch #6"));
Serial.println(F("(9) ToggleSwitch #7"));
Serial.println(F("(10) ToggleSwitch #8"));
Serial.println(F("(menu) send anything else or press on board reset button\n"));
while (!Serial.available());
// Read data from serial monitor if received
while (Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{
if(c == '1')
Serial.println(F("Now Testing Slide Pot - X-Large (10k Linear Taper) #1"));
else if(c == '2')
Serial.println(F("Now Testing Slide Pot - X-Large (10k Linear Taper) #2"));
else if(c == '3')
Serial.println(F("Now Testing ToggleSwitch #1"));
else if(c == '4')
Serial.println(F("Now Testing ToggleSwitch #2"));
else if(c == '5')
Serial.println(F("Now Testing ToggleSwitch #3"));
else if(c == '6')
Serial.println(F("Now Testing ToggleSwitch #4"));
else if(c == '7')
Serial.println(F("Now Testing ToggleSwitch #5"));
else if(c == '8')
Serial.println(F("Now Testing ToggleSwitch #6"));
else if(c == '9')
Serial.println(F("Now Testing ToggleSwitch #7"));
else if(c == '10')
Serial.println(F("Now Testing ToggleSwitch #8"));
else
{
Serial.println(F("illegal input!"));
return 0;
}
time0 = millis();
return c;
}
}
}
every time i add it to hourly or web editor and verify it gives me endless errors
i need this project ASAP
PLS help
edit
used firmware but this error was written twice
warning: multi-character character constant [-Wmultichar]
else if(menuOption == '10') {
^~~~
Firmware.ino (9.52 KB)