SEBASFELIPE1982

Hi, I hope you are very well. I have many projects with millumin, it seems to me a spectacular program. There goes my consultation and where I need your help urgently. I am in a project of a xray slider with millumin and arduino. but I've been stuck in something maybe very simple. I have programmed my arduino with code for the functioning of the encoder, it works perfect for me. Now I just need to increase in this code functions so that by means of millumin commands, the arduino activates 2 relays. please your help since I do not have very good programming knowledge. I already have the dev-kit delivered by you installed. Thank you I await your comments. int encoderPin1 = 2; int encoderPin2 = 3; volatile int lastEncoded = 0; volatile long encoderValue = 0; long lastencoderValue = 0; int lastMSB = 0; int lastLSB = 0; void setup() { Serial.begin (9600); pinMode(encoderPin1, INPUT_PULLUP); pinMode(encoderPin2, INPUT_PULLUP); digitalWrite(encoderPin1, HIGH); //turn pullup resistor on digitalWrite(encoderPin2, HIGH); //turn pullup resistor on //call updateEncoder() when any high/low changed seen //on interrupt 0 (pin 2), or interrupt 1 (pin 3) attachInterrupt(0, updateEncoder, CHANGE); attachInterrupt(1, updateEncoder, CHANGE); } void loop(){ //Do stuff here Serial.println(encoderValue); //delay(1000); //just here to slow down the output, and show it will work even during a delay } void updateEncoder(){ int MSB = digitalRead(encoderPin1); //MSB = most significant bit int LSB = digitalRead(encoderPin2); //LSB = least significant bit int encoded = (MSB << 1) |LSB; //converting the 2 pin value to single number int sum = (lastEncoded << 2) | encoded; //adding it to the previous encoded value if(sum == 0b1101 || sum == 0b0100 || sum == 0b0010 || sum == 0b1011) encoderValue ++; if(sum == 0b1110 || sum == 0b0111 || sum == 0b0001 || sum == 0b1000) encoderValue --; lastEncoded = encoded; //store this value for next time }

About

Username
SEBASFELIPE1982
Joined
Visits
9
Last Active
Roles
Member

Activity

  • Not much happening here, yet.