int potum = A2;
int potdois = A1;
int pottres = A0;
int val1;
int val2;
int val3;
int vale1;
int vale2;
int vale3;
int botao = 2;
int carregar;
int botao2 = 6;
int carregar2;
#include <Servo.h>
Servo servoum;
Servo servodois;
Servo servotres;
//int ser1 = 400
//int ser2 = 400
//sda no A4
//scl no A5
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
// put your setup code here, to run once:
Serial.begin(9600);
servoum.attach(9);
servodois.attach(10);
servotres.attach(11);
pinMode(botao, INPUT_PULLUP);
pinMode(botao2, INPUT_PULLUP);
}
void loop() {
carregar = digitalRead(botao);
carregar2 = digitalRead(botao2);
switch (carregar2) {
case LOW:
display.clearDisplay (); // clear display
display.setCursor (0,5); // position the cursor
display.setTextSize (2); // medium size font
display.setTextColor (WHITE); // white is not default !
display.print (vale1);
display.setCursor (50,5);
display.setTextSize (2); // smallest font
display.print (vale2);
display.display ();
display.setCursor (90,5);
display.setTextSize (2); // smallest font
display.print (vale3);
display.display ();
break;
case HIGH:
break;
}
switch (carregar) {
case LOW:
vale1= 90;
vale2= 90;
vale3= 90;
// statements
break;
case HIGH:
// put your main code here, to run repeatedly:
val1 = analogRead(potum);
val2 = analogRead(potdois);
val3 = analogRead(pottres);
// delay(15);
Serial.print("Servo 1:");
Serial.println(val1);
Serial.print("Servo 2:");
Serial.println(val2);
//Serial.println(val3);
vale1 = map(val1, 0, 720, 0, 180);
vale2 = map(val2, 0, 720, 0, 180);
vale3= map(val3, 0, 720, 0, 180);
break;
}
servoum.write(vale1);
//val2 = 180-val2;
servodois.write(vale2);
servotres.write(vale3);
/*
Serial.print("Servo 1:");
Serial.print(val1);
Serial.print(" Servo 2:");
Serial.println(val2);
Serial.print(" Servo 3:");
Serial.println(val3);
*/
}