duncantexasbellecraig
Published © CC BY

4 Channel miniscope

As some body who works in automation the troubleshooting of incremental rotary encoders is very important. So I have made myself a scope

BeginnerShowcase (no instructions)284
4 Channel miniscope

Things used in this project

Story

Read more

Schematics

Image of wiring

Minimal wiring is required for this scope

Code

The code for the project

Arduino
Here's the code for the Uno
int potentiometer_pin = A0;                                     //Define the analog input pin
int potentiometer_pin1 = A1;                                     //Define the analog input pin
int potentiometer_pin2 = A2;                                     //Define the analog input pin
int potentiometer_pin3 = A3;                                     //Define the analog input pin
const int buttonPin = 8;         // the number of the pushbutton pin
// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  Serial.begin(9600);                                           //Default baud rate of the Nextion TFT is 9600
  pinMode(potentiometer_pin, INPUT);                            //Define pin as input
  pinMode(potentiometer_pin1, INPUT);                            //Define pin as input
  pinMode(potentiometer_pin2, INPUT);                            //Define pin as input
  pinMode(potentiometer_pin3, INPUT);                            //Define pin as input
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {
    routine0();
    routine1();
    routine2();
    routine3();
  }

}

void routine0() {

  int  Value = map(analogRead(potentiometer_pin), 0, 1024, 0, 200); //Read the pot value ann map it to 0.255 (max value of waveform=255)
  String Tosend = "add ";                                       //We send the string "add "
  Tosend += 1;                                                  //send the id of the block you want to add the value to
  Tosend += ",";
  Tosend += 0;                                                  //Channel of taht id, in this case channel 0 of the waveform
  Tosend += ",";
  Tosend += Value;                                              //Send the value and 3 full bytes
  //Send the value and 3 full bytes
  Serial.print(Tosend);
  Serial.write(0xff);
  Serial.write(0xff);
  Serial.write(0xff);
}

void routine1() {

  int  Value1 = map(analogRead(potentiometer_pin1), 0, 1024, 0, 200); //Read the pot value ann map it to 0.255 (max value of waveform=255)
  String Tosend = "add ";                                       //We send the string "add "
  Tosend += 1;                                                  //send the id of the block you want to add the value to
  Tosend += ",";
  Tosend += 1;                                                  //Channel of taht id, in this case channel 0 of the waveform
  Tosend += ",";
  Tosend += (Value1 + 10);
  //Send the value and 3 full bytes
  Serial.print(Tosend);
  Serial.write(0xff);
  Serial.write(0xff);
  Serial.write(0xff);

}

void routine2() {

  int  Value = map(analogRead(potentiometer_pin2), 0, 1024, 0, 200); //Read the pot value ann map it to 0.255 (max value of waveform=255)
  String Tosend = "add ";                                       //We send the string "add "
  Tosend += 1;                                                  //send the id of the block you want to add the value to
  Tosend += ",";
  Tosend += 2;                                                  //Channel of taht id, in this case channel 0 of the waveform
  Tosend += ",";
  Tosend += (Value + 20);                                            //Send the value and 3 full bytes
  //Send the value and 3 full bytes
  Serial.print(Tosend);
  Serial.write(0xff);
  Serial.write(0xff);
  Serial.write(0xff);
}

void routine3() {

  int  Value1 = map(analogRead(potentiometer_pin3), 0, 1024, 0, 200); //Read the pot value ann map it to 0.255 (max value of waveform=255)
  String Tosend = "add ";                                       //We send the string "add "
  Tosend += 1;                                                  //send the id of the block you want to add the value to
  Tosend += ",";
  Tosend += 3;                                                  //Channel of taht id, in this case channel 0 of the waveform
  Tosend += ",";
  Tosend += (Value1 + 30);
  //Send the value and 3 full bytes
  Serial.print(Tosend);
  Serial.write(0xff);
  Serial.write(0xff);
  Serial.write(0xff);

}

Hmi project

Copy to micro sd card and load onto screen

Credits

duncantexasbellecraig

duncantexasbellecraig

1 project • 0 followers

Comments