teslaTruck

Its the tesla truck. but better

BeginnerFull instructions provided2 hours141
teslaTruck

Things used in this project

Hardware components

Argon
Particle Argon
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Darlington High Power Transistor
Darlington High Power Transistor
×1

Story

Read more

Schematics

fritzing circuit diagram

the particle argon turns the servo to three specific positions. The servo has a shaft attached to it and it taped to the potentiometer. when the servo spins, it rotates the potentiometer and increases/decreases the resistance therefore slowing down or speeding up the motor.

adafruit dashboard

Code

make servo turn to actuate potentiometer through button

C/C++
you press go
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
int buttonPin = 2;  // the pin that the pushbutton is attached to
int pos = 0;    // variable to store the servo position
int buttonState = 0;  // variable to store the button state
int servoPositions[3] = {0, 90, 180}; // array to store the servo positions

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  pinMode(buttonPin, INPUT); // sets the digital pin 2 as input
}

void loop() {
  buttonState = digitalRead(buttonPin); // read the state of the pushbutton
  if (buttonState == HIGH) { // if button is pressed
    pos++;  // increment the position
    if (pos >= 3) { // if position is out of bounds, reset to 0
      pos = 0;
    }
    myservo.write(servoPositions[pos]); // set the servo position based on the current position index
    delay(1000); // wait for 1 second to allow the servo to move to the new position
  }
}

Credits

Mackay Burke
3 projects • 3 followers
I strive to be the next MAC
Contact
Peyton Senffner
2 projects • 0 followers
Contact
Malek Hajahmad
1 project • 0 followers
Contact
Evan Huber
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.