Skip to content

Instantly share code, notes, and snippets.

@deviceplususer
Created January 8, 2020 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deviceplususer/b3213c77cdde0e5cf45ca93d0bfcb0ee to your computer and use it in GitHub Desktop.
Save deviceplususer/b3213c77cdde0e5cf45ca93d0bfcb0ee to your computer and use it in GitHub Desktop.
#include <SparkFun_TB6612.h>
#define AIN1 2
#define AIN2 4
#define PWMA 5
#define STBY 9
const int offsetA = 1;
Motor motor1 = Motor(AIN1, AIN2, PWMA, offsetA, STBY);
void setup()
{
Serial.begin(9600);
}
void loop()
{
int volume = analogRead(A0);
volume = map( volume, 0, 1023, 30, 255 );
motor1.drive( volume );
Serial.println( volume );
delay(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment