Description
I created a panda massage pad using dc motor, FSR, and Arduino.
Components
- 1 Arduino
- 1 DC Motor
- 1 Transistor
- 1 Battery
- 2 Resistors
- 1 Breadboard
Code
int potPin = A0; // select the input pin for the potentiometer
int motorPin = 9; // select the pin for the Motor
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(potPin); // read the value from the sensor, between 0 - 1024
Serial.println(val);
analogWrite(motorPin, val/4); // analogWrite can be between 0-255
}