Here I begin a massive tutorial on Arduino and Electronics! In this first video I cover Arduino Basics, Electricity, Ground, Voltage, Current, Resistance, Power, Protecting Components, LEDs, Breadboards, Arduino Coding, Ohm’s Law, Generating Different Voltages with Arduino, 2 Circuits and much more.
Like always the code I use follows the video below. The kit I’m using for the tutorial is here.
If you like videos like this consider donating $1, or simply turn off Ad Blocking software. Either helps me to continue making free tutorials.
Code from the Video
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
ARDUINO DEMONSTRATION // Create a constant thats value will never change // This will represent pin 3 in our code const int outPin = 3; // Runs once to set important values and define rules void setup() { // State that pin 3 will be used for outputting a current pinMode(outPin, OUTPUT); // Used to communicate between the Arduino and your computer // We wish to transfer 960 characters per second Serial.begin(9600); // Prints a message in the serial monitor Serial.println("Enter 1 or 0"); } void loop() { // Turn the 3 pin on and off from the monitor // Check for the number of bytes we can read from the serial // port. If greater then 0 it is connected if(Serial.available() > 0){ // Read input from serial monitor char ch = Serial.read(); // If 1 is entered in the serial monitor turn pin 3 on if(ch == '1'){ digitalWrite(outPin, HIGH); // If 0 is entered stop current from flowing from pin 3 } else if(ch = '0'){ digitalWrite(outPin, LOW); } } } // ----- CHANGING VOLTAGE OUTPUT USING ANALOG OUTPUTS ----- // GND to black and 3 to red Multimeter // Pins 3,5,6,9,10 and 11 provide variable output // They turn on and off voltage rapidly instead of just 5V // All pulse 500 times per second except 5 & 6 which // pulse 980 times // By varying how long a signal is high you can control the dimming / color // of an LED, the speed of a motor, a voltage, etc. const int outputPin = 3; void setup(){ pinMode(outputPin, OUTPUT); Serial.begin(9600); Serial.println("Enter Voltage 0 - 5"); } void loop(){ if(Serial.available() > 0){ // Get the users requested voltage float volts = Serial.parseFloat(); // Convert to requested voltage int reqVolts = volts * 255.0 / 5.0; // Output requested voltage from pin analogWrite(outputPin, reqVolts); } } |
Leave a Reply