/*
  Uno with Scope https://github.com/Dlloydev/Wokwi-Chip-Scope
        and https://github.com/Dlloydev/Wokwi-Chip-PWM
        and https://github.com/drf5n/Wokwi-Chip-FrequencyCounter

  Wokwi Uno https://wokwi.com/projects/390819301187622913
  Wokwi Mega: https://wokwi.com/projects/390819455604080641
  Wokwi ESP32S3 https://wokwi.com/projects/404720144387009537

  See also https://wokwi.com/projects/359331973918199809

*/


const byte INA = 10;
const byte INB = 9;
const byte trigPin = 3;
const byte PotPin = A0;

void setup() {
  Serial.begin(115200);
  pinMode(INA, OUTPUT);
  pinMode(INB, OUTPUT);
  pinMode(trigPin, OUTPUT);
  analogWrite(trigPin,127);
}


/*

  Running Blink.ino
  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://docs.arduino.cc/hardware/

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  https://docs.arduino.cc/built-in-examples/basics/Blink/
*/

// the loop function runs over and over again forever
void loop() {
  static int lastPot = -1;
  int pot = analogRead(PotPin)/2-255;
  if (pot != lastPot) {
    lastPot = pot;
    if (pot >= 0) {
      analogWrite(INA, pot);
      analogWrite(INB, 0);
    } else {
      analogWrite(INA, 0);
      analogWrite(INB, -pot);
    }
  }
}
Loading chip...chip-scope
Loading chip...chip-scope
Wokwi UnoScope https://wokwi.com/projects/390819301187622913
cnt/meas
en/!dis
stepper-escBreakout