hello,
i am trying to make a arduino menu in wich you can use functions to adjust dc motor speed. i am stuck and dont know what to do.
can anybody help me?
i also have a raspberry pi but dont know if i can connect pins etc to (PYTHON) pi3b+
i kind of have an idea of how to program in python its al kind of logical, so my question does someone have an advanced functioning menu
i have tryd some ways
with menu.h for instance and there are cases, like case 'w' up, 's' down.
what do i need to do, can find by googling arduino #include <menu.h><submenu.h> i couldnt change this menu to my own.
anybody got any eperience =)
if (button1) is (on/off) case is 'w" etc?!?
i didnt succeed in arduino with this .menu libraries
i also have tried this way:(down below)
i dont know how to go on, controlling functions and displaying the values(rpm motor is running)
can anybody help me pls
thanks in advance!
jasper
#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);
//input and control logic
const int numOfInputs = 4;
const int inputPins[numOfInputs] = {8,9,10,11};
const int outputPin = A1;
int inputState[numOfInputs];
int lastInputState[numOfInputs] = {LOW,LOW,LOW,LOW};
bool inputFlags[numOfInputs] = {LOW,LOW,LOW,LOW};
long lastDebounceTime[numOfInputs] = {0,0,0,0};
long debounceDelay = 5;
//lcd menu logic
const int numOfScreens = 4;
int currentScreen = 0;
String screens[numOfScreens] [2] = {{"LIGHT","LED"}, {"HEIGHT","CM"}, {"MOTOR SPEED","RPM"}, {"MOTOR DIRECTION","M-DIR"}};
int parameters[numOfScreens];
String parametersUnits[numOfScreens] = {"LED","CM","RPM","M-DIR"};
//LED logic
int numOfLEDInputs = 2;
const int inputPinsLED[numOfInputs] = {12,13};
int LEDState = 0;
int lastLEDInputState[numOfInputs] = {LOW,LOW};
bool inputLEDFlags[numOfInputs] = {LOW,LOW};
int inputCounters[numOfInputs];
long lastLEDDebounceTime[numOfInputs] = {0,0};
long LEDdebounceDelay = 50;
void setup() {
for(int j = 0; j < numOfInputs; j++){
pinMode(inputPins[j], INPUT);
digitalWrite(inputPins[j], HIGH); //pull-up 20k
for(int i = 0; i <numOfInputs; i++) {
pinMode(inputPins*, INPUT);*
_ digitalWrite(inputPins*, HIGH); //pull-up 20k*_
* }*
* }*
* Serial.begin(9600);*
* pinMode(outputPin, OUTPUT); //digitalWrite(outputPin, outputState);*
* lcd.begin(16, 2);*
}
void loop() {
* setInputFlags();*
// resolveInputFlags();
// resolveOutputs();
}
void setInputFlags() {
* for(int i = 0; i < numOfInputs; i++) {*
_ int reading = digitalRead(inputPins*);
if (reading != lastInputState) {*
lastDebounceTime = millis();_
* }*
* }*
_ if ((millis() - lastDebounceTime*) > debounceDelay) {
if (reading != inputState) {
inputState = reading;
if (inputState == HIGH) {
serial.println;
inputFlags = HIGH;
}
}
}
// lastInputState = reading;
}
for(int j = 0; j < numOfInputs; j++) {
int reading = digitalRead(inputPins[j]);
if (reading != lastInputState[j]) {
lastDebounceTime[j] = millis();
}
if ((millis() - lastDebounceTime[j]) > debounceDelay) {
if (reading != inputState[j]) {
inputState[j] = reading;
if (inputState[j] == HIGH) {
//outputState = !outputState;
inputFlags[j] = HIGH;
}
}
}
lastInputState[j] = reading;
}
void resolveInputFlags() {
for(int i = 0; i < numOfInputs; i++) {
if(inputFlags == HIGH) {
inputAction(i);
//Serial.Println(i);
Serial.println(currentScreen);
inputFlags = LOW;
printScreen();
}
}
for(int j = 0; j < numOfInputs; j++) {
if(inputFlags[j] == HIGH) {
//input toggle logic*
* inputCounters[j]++;
updateLEDState(j);
printString(j);
inputFlags[j] = LOW;
}
}
}
void inputAction(int input) {
if(input == 0) {
if (currentScreen == 0) {
currentScreen = numOfScreens-1;
}else{
currentScreen--;
}
}else if(input == 1) {
if (currentScreen == numOfScreens-1){
currentScreen = 0;
}else{
currentScreen++;
}
}else if(input == 2) {
parameterChange(0);
}else if(input == 3) {
parameterChange(1);
}
}
void parameterChange(int key) {
if(key == 0) {
parameters[currentScreen]++;
}else if(key == 1) {
parameters[currentScreen]--;
}
}
void printString(int output) {
Serial.print("input ");
Serial.print("output");
Serial.print(" was pressed ");
Serial.print("inputCounters[output]");
Serial.println(" times.");
}
void updateLEDState(int input);
// input 0 = State 0 and 1*
* if(input == 0) {
if(LEDState == 0) {
LEDState = 1;
}else{
LEDState = 0;
}
// input 1 = State 2 to 6*
* }else if(input == 1) { // 2,3,4,5,6,2,3,4,5,6,2,
if(LEDState == 0 || LEDState == 1 || LEDState > 5);
LEDState = 2;
}else{
LEDState++;
}
}
}
//void printScreen() {
//lcd.clear();
//lcd.print(screens[currentScreen][0]);
//lcd.setCursor(0,1);
//lcd.print(parameters[currentScreen]);
//lcd.print(" ");
//lcd.print(screens[currentScreen][1]);*
if anybody can help me here,
thanks in advance!_