Vaughn Johnson
Published

Project 09 - DIG3602C

Vaughn Johnson UCF-Spring 2023-DIG3602C-Davis Project 09

BeginnerWork in progress53
Project 09 - DIG3602C

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
9V battery (generic)
9V battery (generic)
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×1
Power MOSFET N-Channel
Power MOSFET N-Channel
×1
Resistor 10k ohm
Resistor 10k ohm
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1
DC motor (generic)
×1
Snap-on Connector, For 1 9-V Battery
Snap-on Connector, For 1 9-V Battery
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Picture

Schematic

Code

p09_MotorizedPinwheel.ino

C/C++
const int switchPin = 2;  // the number of the switch pin
const int motorPin = 9;   // the number of the motor pin

int switchState = 0;  // variable for reading the switch's status

void setup() {
  // initialize the motor pin as an output:
  pinMode(motorPin, OUTPUT);
  // initialize the switch pin as an input:
  pinMode(switchPin, INPUT);
}

void loop() {
  // read the state of the switch value:
  switchState = digitalRead(switchPin);

  // check if the switch is pressed.
  if (switchState == HIGH) {
    // turn motor on:
    digitalWrite(motorPin, HIGH);
  } else {
    // turn motor off:
    digitalWrite(motorPin, LOW);
  }
}

Credits

Vaughn Johnson
11 projects • 3 followers

Comments