Zdravím
potřeboval bych na arduinu ATMEGA328 uvolnit jeden analogový vstup , takže bych potřeboval nahradit jeden potenciometr ,dvěma tlačítky na dig vstupech a ovládat + a -
poradí mi někdo jak nato ?
potřebuji nahradit toto :
const int analogInPin3 = 5; // D Analog input pin that the potentiometer
int sensorValue3 = 0; // value read from the pot
int outputValue3 = 0; // value output to the x
sensorValue3 = analogRead (analogInPin3);
outputValue3 = map(sensorValue3, 0, 1023, 0, 500);
Arduino
co si vytvořit nějaký shorinteger do kterého budeš pomocí tlačítek přidávat a ubírat s kontrolou max a min hodnoty a z to pak použiješ jako hodnotu na místo analogového vstupu?
XpertMill, Gravos, Ninos, Galaad
IQ156
-1500Kč, -520Kč, -1čokoláda, - 28000Kč
www.freeair.cz www.rotexelectric.eu www.retrofitcnc.cz
IQ156
-1500Kč, -520Kč, -1čokoláda, - 28000Kč
www.freeair.cz www.rotexelectric.eu www.retrofitcnc.cz
možná nějak takto( dlouho jsem nic nepsal tak spíš pro inspiraci)
jen tam dodělat ochranu na min a max hodnoty a změnit některé datové formáty.
const int buttonPinpls = 2;
const int buttonPinminus = 3;
int outputValue3 = 0; // value output to the x
int potstatepls = 0;
int potstateminus = 0;
int potstate = 0;
void setup() {
pinMode(buttonPinpls, INPUT);
pinMode(buttonPinminus, INPUT);
}
void loop(){
potstatepls = digitalRead(buttonPinpls);
potstateminus = digitalRead(buttonPinminus);
if (potstatepls == HIGH) {
potstate = potstate + 1;
}
if (potstateminus == HIGH) {
potstate = potstate - 1;
}
outputValue3 = potstate;
}
jen tam dodělat ochranu na min a max hodnoty a změnit některé datové formáty.
const int buttonPinpls = 2;
const int buttonPinminus = 3;
int outputValue3 = 0; // value output to the x
int potstatepls = 0;
int potstateminus = 0;
int potstate = 0;
void setup() {
pinMode(buttonPinpls, INPUT);
pinMode(buttonPinminus, INPUT);
}
void loop(){
potstatepls = digitalRead(buttonPinpls);
potstateminus = digitalRead(buttonPinminus);
if (potstatepls == HIGH) {
potstate = potstate + 1;
}
if (potstateminus == HIGH) {
potstate = potstate - 1;
}
outputValue3 = potstate;
}
XpertMill, Gravos, Ninos, Galaad
IQ156
-1500Kč, -520Kč, -1čokoláda, - 28000Kč
www.freeair.cz www.rotexelectric.eu www.retrofitcnc.cz
IQ156
-1500Kč, -520Kč, -1čokoláda, - 28000Kč
www.freeair.cz www.rotexelectric.eu www.retrofitcnc.cz