├── Lesson 10 - Ultrasonic Sensor Module ├── HC-SR04 │ ├── SR04.cpp │ └── SR04.h ├── Lesson10.fzz ├── Lesson10_bb.png ├── README.md ├── UltrasonicDistance │ └── UltrasonicDistance.ino ├── UltrasonicDistanceLCD │ └── UltrasonicDistanceLCD.ino ├── UltrasonicSensorLCD.fzz ├── UltrasonicSensorLCD_bb.png ├── UltrasonicSensorLCD_schem.png └── mySR04_Example │ └── mySR04_Example.ino ├── Lesson 11 - Keypad Membrane Switch Module ├── Analog_keypad │ └── Analog_keypad.ino ├── Keypad_4x4_1analogPin.fzz ├── Keypad_4x4_1analogPin_bb.png ├── Keypad_4x4_1analogPin_schem.png ├── Ladder.xlsm └── README.md ├── Lesson 12 - DHT11 ├── DHT11_Decimal │ └── DHT11_Decimal.ino └── README.md ├── Lesson 13 - Analog Joystick Module ├── Analog_Joystick_OLEDcursor │ └── Analog_Joystick_OLEDcursor.ino └── README.md ├── Lesson 14 - IR Receiver Module ├── IR_Receiver_Module │ └── IR_Receiver_Module.ino └── README.md ├── Lesson 15 - MAX7219 Module ├── LEDGraphicToHex.xlsm ├── MyMarqueeText │ └── MyMarqueeText.ino └── README.md ├── Lesson 16 - GY-521 Module ├── MPU-6050_expanded │ └── MPU-6050_expanded.ino └── README.md ├── Lesson 17 - HC-SR501 ├── HC-SR501_Demo │ └── HC-SR501_Demo.ino ├── HC-SR501_plus.fzz ├── HC-SR501_plus_bb.jpg ├── HC-SR501_plus_schem.jpg └── README.md ├── Lesson 18 - Water Level Detection Sensor Module ├── README.md └── Water_level │ └── Water_level.ino ├── Lesson 19 - Real Time Clock Module ├── AT24C32N datasheet.pdf ├── DS3231 schematic.png ├── README.md ├── RTC_Alarm │ ├── RTC_Alarm.ino │ ├── RTC_Alarm.ino.standard.hex │ └── RTC_Alarm.ino.with_bootloader.standard.hex ├── RTC_bb.png ├── RTC_schem.png ├── SimpleAlarmClock-1.0.zip └── Thick Film Chip Network Resistors.pdf ├── Lesson 20 - Sound Sensor Module ├── KY-038_schematic.png ├── Lesson20.fzz ├── Lesson20_bb.png ├── Lesson20_schem.png ├── README.md ├── SoundSensor.fzz ├── SoundSensor │ └── SoundSensor.ino ├── SoundSensor_bb.png └── SoundSensor_schem.png ├── Lesson 21 - RC522 RFID Module ├── README.md └── RFID_module │ └── RFID_module.ino ├── Lesson 22 - LCD Display ├── HelloWorld │ └── HelloWorld.ino ├── I2C_check │ └── I2C_check.ino ├── LCD1602A.fzz ├── LCD1602A_I2C.fzz ├── LCD1602A_I2C_bb.png ├── LCD1602A_I2C_schem.png ├── LCD1602A_bb.png ├── LCD1602A_schem.png ├── README.md └── fdebrabander-LiquidCrystal-I2C.zip ├── Lesson 23 - Thermometer ├── README.md ├── Thermistor Calculator.xlsx ├── Thermistor.fzz ├── Thermistor_bb.png ├── Thermistor_schem.png └── Thermometer │ └── Thermometer.ino ├── Lesson 24 - 74HC595 Shift Register ├── 74HC595-shift-register-pinout.png ├── 74HC595.fzz ├── 74HC595_bb.png ├── 74HC595_schem.png ├── B2B_74HC595.fzz ├── B2B_74HC595_bb.png ├── B2B_74HC595_schem.png ├── README.md ├── SR_74HC595 │ └── SR_74HC595.ino ├── SR_74HC595_16bit │ └── SR_74HC595_16bit.ino └── SR_74HC595_32bit │ └── SR_74HC595_32bit.ino ├── Lesson 26 - Photocell ├── PhotoCell.fzz ├── PhotoCell_bb.png └── PhotoCell_schem.png ├── Lesson 27 - 74HC595 and Segment Display ├── 7-SegmentDisplay │ └── 7-SegmentDisplay.ino ├── 74HC595_7SegmentDisplay.fzz ├── 74HC595_7SegmentDisplay_bb.png ├── 74HC595_7SegmentDisplay_schem.png ├── 74HC595_SegmentDisplay.xlsx └── README.md ├── Lesson 28 - 4 Digit 7 Segment Display ├── 4Digit_7SegmentDisplay.xlsx ├── 4_digit_proper.fzz ├── 4_digit_proper_bb.png ├── 4_digit_proper_schem.png ├── 4digit7segment_PinLayout.png ├── 5641AS_DataSheet.pdf ├── Four_Digit_HexCounter │ └── Four_Digit_HexCounter.ino └── README.md ├── Lesson 29 - DC Motors ├── DC_Motor.fzz ├── DC_Motor │ └── DC_Motor.ino ├── DC_Motor_bb.png ├── DC_Motor_schem.png ├── Datasheet_pins.png └── L293D_Pinout3.png ├── Lesson 4 - RGB LED ├── Lesson4.fzz ├── Lesson4_bb.png ├── Lesson4_schem.png ├── README.md └── RGB_LED │ └── RGB_LED.ino ├── Lesson 5 - Digital Inputs ├── DigitalInput_Debounce │ ├── DigitalInput_Debounce.ino │ ├── Lesson 5 Single Button Sketch.fzz │ ├── Lesson 5 Single Button Sketch_bb.png │ └── Lesson 5 Single Button Sketch_schem.png ├── DigitalInput_DeepSleep │ └── DigitalInput_DeepSleep.ino ├── Lesson 5 Sketch.fzz ├── Lesson 5 Sketch_bb.png ├── Lesson 5 Sketch_schem.png ├── README.md └── Script.pdf ├── Lesson 6 - Active Buzzer ├── Lesson 6.fzz ├── Lesson 6_bb.png ├── Lesson 6_schem.png ├── MorseCode_Translator │ ├── Morse Code Translator.fzz │ ├── Morse Code Translator_bb.png │ ├── Morse Code Translator_schem.png │ └── MorseCode_Translater │ │ └── MorseCode_Translater.ino └── README.md ├── Lesson 7 - Passive Buzzer ├── HappyBirthday │ └── HappyBirthday.ino ├── Lesson7.fzz ├── Lesson7_bb.png ├── Lesson7_schem.png ├── MusicPlayer.fzz ├── MusicPlayer2.fzz ├── MusicPlayer2_bb.png ├── MusicPlayer2_schem.png ├── MusicPlayer_bb.png ├── MusicPlayer_schem.png ├── README.md ├── StarWarsImperialMarch │ └── StarWarsImperialMarch.ino └── SuperMario │ └── SuperMario.ino ├── Lesson 8 - Tilt Ball Switch ├── Magic8-Ball.fzz ├── Magic8-Ball_bb.png ├── Magic8-Ball_schem.png ├── Magic_8-Ball │ └── Magic_8-Ball.ino ├── README.md └── myBall_Switch │ └── myBall_Switch.ino ├── Lesson 9 - Servo ├── Lesson 9 Servo_RotaryEncoder.fzz ├── Lesson 9 Servo_RotaryEncoder_bb.png ├── Lesson 9 Servo_RotaryEncoder_schem.png ├── README.md └── ServoRangeCal_Ctrl │ └── ServoRangeCal_Ctrl.ino ├── README.md ├── UNLICENSE ├── _config.yml └── library.properties /Lesson 10 - Ultrasonic Sensor Module/HC-SR04/SR04.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "SR04.h" 3 | 4 | SR04::SR04(int echoPin, int triggerPin) { 5 | _echoPin = echoPin; 6 | _triggerPin = triggerPin; 7 | pinMode(_echoPin, INPUT); 8 | pinMode(_triggerPin, OUTPUT); 9 | _autoMode = false; 10 | _distance = 999.; 11 | } 12 | 13 | 14 | float SR04::Distance() { 15 | float d = 0.; 16 | _duration = 0; 17 | digitalWrite(_triggerPin, LOW); 18 | delayMicroseconds(2); 19 | digitalWrite(_triggerPin, HIGH); 20 | delayMicroseconds(10); 21 | digitalWrite(_triggerPin, LOW); 22 | delayMicroseconds(2); 23 | _duration = pulseIn(_echoPin, HIGH, PULSE_TIMEOUT); 24 | d = MicrosecondsToCentimeter(_duration); 25 | delay(25); 26 | return d; 27 | } 28 | 29 | float SR04::DistanceAvg(int wait, int count) { 30 | float min, max, avg, d; 31 | min = 999.; 32 | max = 0.; 33 | avg = d = 0.; 34 | 35 | if (wait < 25) { 36 | wait = 25; 37 | } 38 | 39 | if (count < 1) { 40 | count = 1; 41 | } 42 | 43 | for (int x = 0; x < count + 2; x++) { 44 | d = Distance(); 45 | 46 | if (d < min) { 47 | min = d; 48 | } 49 | 50 | if (d > max) { 51 | max = d; 52 | } 53 | 54 | avg += d; 55 | } 56 | 57 | // substract highest and lowest value 58 | avg -= (max + min); 59 | // calculate average 60 | avg /= count; 61 | return avg; 62 | } 63 | 64 | void SR04::Ping() { 65 | _distance = Distance(); 66 | } 67 | 68 | float SR04::getDistance() { 69 | return _distance; 70 | } 71 | 72 | float SR04::MicrosecondsToCentimeter(long duration) { 73 | float d = (duration * 100.) / 5882.; 74 | //d = (d == 0)? 999:d; 75 | return d; 76 | } 77 | 78 | long SR04::pingTime() { 79 | return _duration; 80 | } 81 | 82 | 83 | -------------------------------------------------------------------------------- /Lesson 10 - Ultrasonic Sensor Module/HC-SR04/SR04.h: -------------------------------------------------------------------------------- 1 | #ifndef SR04_H 2 | #define SR04_H 3 | 4 | #if defined(ARDUINO) && ARDUINO >= 100 5 | #include "Arduino.h" 6 | #else 7 | #include "WProgram.h" 8 | #endif 9 | //#include "pins_arduino.h" 10 | 11 | #include 12 | 13 | #define PULSE_TIMEOUT 150000L // 100ms 14 | #define DEFAULT_DELAY 10 15 | #define DEFAULT_PINGS 5 16 | class SR04 { 17 | public: 18 | 19 | /** 20 | * Constructor 21 | * Ultrasonic sensor SR04, four connections pins 22 | * VCC, ECHO, TRIGGER, GND 23 | *
24 | * \param echoPin digital INPUT-Pin for measuring distance 25 | * \param triggerPin if 10us high a trigger signal is generated from 26 | * SR04 27 | * 28 | * \return void 29 | */ 30 | SR04(int echoPin, int triggerPin); 31 | 32 | /** 33 | * Do a measurment for this sensor. Return distance as long 34 | * in centimenter 35 | * \return long distance in centimeter 36 | */ 37 | float Distance(); 38 | 39 | /** 40 | * Do count measurents and calculate the average. 41 | * To avoid defilement from ow/high peaks, min/max values 42 | * are substracted from the average 43 | * 44 | * \param wait delay between measurements, default = DEFAULT_DELAY/ms 45 | * \param count number of measurements, default DEFAULT_PINGS 46 | * \return long distance in centimeter 47 | **/ 48 | float DistanceAvg(int wait=DEFAULT_DELAY, int count=DEFAULT_PINGS); 49 | 50 | /** 51 | * Do only a ping. Get result with methode getDistance() 52 | * 53 | * \param keine 54 | */ 55 | void Ping() ; 56 | 57 | /** 58 | * return latest distance. Methode Ping() should be called before 59 | * \param keine 60 | * \return Distanz in Zentimeter 61 | */ 62 | float getDistance(); 63 | 64 | /** 65 | * return latest duration time 66 | * can be called after a distance method call 67 | * returns a long 68 | */ 69 | long pingTime(); 70 | 71 | 72 | private: 73 | /** 74 | * Do the measurement calculation and return result in centimeter 75 | * SR04 measure echo time to obstacle and return way. 76 | *
77 | * Sound travels with 340m/sec 78 | *
79 | * Example: Obstace 100cm away from SR04. Measure time is 100cm to 80 | * obstacle and 100cm return = 200cm 81 | *
82 | * 1sec = 1000ms = 1,000,000uS 83 | * 1,000,000 / 340 = Distance in microseconds for 100cm 84 | * 2941uS fuer 100cm = 5882 uS fuer 200cm 85 | * 86 | * duration / 5882 * 100 = distance in cm 87 | */ 88 | float MicrosecondsToCentimeter(long duration); 89 | 90 | float _currentDistance; 91 | int _echoPin, _triggerPin; 92 | long _duration; 93 | float _distance; 94 | bool _autoMode; 95 | }; 96 | #endif 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Lesson 10 - Ultrasonic Sensor Module/Lesson10.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 10 - Ultrasonic Sensor Module/Lesson10.fzz -------------------------------------------------------------------------------- /Lesson 10 - Ultrasonic Sensor Module/Lesson10_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 10 - Ultrasonic Sensor Module/Lesson10_bb.png -------------------------------------------------------------------------------- /Lesson 10 - Ultrasonic Sensor Module/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 10 - Ultrasonic Sensor Module/README.md -------------------------------------------------------------------------------- /Lesson 10 - Ultrasonic Sensor Module/UltrasonicDistance/UltrasonicDistance.ino: -------------------------------------------------------------------------------- 1 | /*Ultrasonic Distance - using the HC-SR04 Ultrasonic Sensor Module 2 | * By Ricardo Moreno 3 | * 02/13/208 4 | * 5 | * Using the Ultrasonic Sensor without a Library 6 | * 7 | * Inspired by: 8 | * LESSON 17: Measure Speed of Sound with Arduino and Ultrasonic Sensor 9 | * https://www.youtube.com/watch?v=eaHRHQ5Ca_U 10 | * 11 | * Lesson 18: Measure Distance with Arduino and Ultrasonic Sensor by Paul McWhorter 12 | * https://www.youtube.com/watch?v=rTM5gZxBPmY 13 | * 14 | * Speed of sound 15 | * changes with with temperature 16 | * at 68 degrees F (20 degrees C) 17 | * 741 Miles per hour 18 | * 1087 feet per sec 19 | * 343.2 meters per second 20 | * 776.5 Miles per Hour (Mph) @ 77 degrees F - Paul McWhorter 21 | * 345.2944 meters per second @ 73 degrees F 22 | * Formula for speed of sound with temperature change: 23 | * sos = 331.5*sqrt(1+C/273.15) - in meters per second - C is degrees C 24 | */ 25 | 26 | // HC-SR04 module pins 27 | const int triggerPin = 12; 28 | const int echoPin = 11; 29 | 30 | //Global Variables 31 | //float speedOfSound = 343.2; //Meters per second @ 20C or 68F 32 | float speedOfSound = 343.2611; //Meters per second @ 67F 33 | float conversionFactor = .0001; //conversion factor for meters to cm & uSec to Sec 34 | unsigned int pingTime = 0; //The time single round trip time - avail after call to distance 35 | unsigned int pingTimeAvg = 0; //The average round trip time - avail after call to distanceAvg 36 | 37 | /* ******************************************************* 38 | * Setup 39 | ********************************************************* */ 40 | void setup() { 41 | pinMode(triggerPin,OUTPUT); 42 | pinMode(echoPin,INPUT); 43 | Serial.begin(9600); //Enable the Serial Monitor 44 | delay(1000); 45 | } 46 | 47 | /* ******************************************************* 48 | * Functions 49 | ********************************************************* */ 50 | float distance(){ 51 | /* distance returns a float value in centimeters 52 | * Parameters: none 53 | */ 54 | float dist = 0.0; 55 | 56 | digitalWrite(triggerPin, LOW); //Set the trigger pin low 57 | delayMicroseconds(5); //pause to let signal settle 58 | digitalWrite(triggerPin, HIGH); 59 | delayMicroseconds(12); //pause HIGH state 60 | digitalWrite(triggerPin, LOW); //Bring trigger down low 61 | //Change the global variable pingtime 62 | pingTime = pulseIn(echoPin, HIGH, 18000);//Measure ping time at echo pin in microseconds 63 | //timeout time in microseconds max about 3 meters 64 | //distance = speed of sound (meters per second) * 1000cm/meter * ping time/2 (uSeconds) * 1sec/1000000uSec 65 | dist = speedOfSound * conversionFactor * pingTime/2; //convert the target distance to cm 66 | return dist; 67 | } 68 | 69 | float distanceAvg(unsigned int wait=1, unsigned int pings=5, unsigned int trimPercent=0){ 70 | /* distanceAvg returns a float value in centimeters 71 | * Parameters: 72 | * [optional]wait - the time between distance checks in milliseconds, 73 | * default value is 1 74 | * [optional]pings - the number of distance checks, default value is 5 75 | * [optional]trimPercent - this is kinda like EXCEL's TRIMMEAN function 76 | * Based upon the trim percentage passed, it 77 | * determines the trim count from minimum and 78 | * maximum values: 79 | * trimCount = rounddown(pings*(trimPercent/100)/2) 80 | * default value is zero which doesn't trim outlying points 81 | */ 82 | float minVal = 0.0; 83 | unsigned long minTime = 0; 84 | float maxVal = 0.0; 85 | unsigned long maxTime = 0; 86 | float d[pings]; 87 | float t[pings]; 88 | float avgDist = 0.0; 89 | unsigned long avgTime = 0; 90 | unsigned int count = pings; 91 | unsigned int trimCount = 0; 92 | 93 | //Parameter checking 94 | if (count < 1) count = 1; 95 | if (wait < 1) wait = 1; //time in milliseconds 96 | if (trimPercent < 0) trimPercent = 0; 97 | if (trimPercent > 100) trimPercent = 100; 98 | 99 | if (trimPercent == 0){ 100 | trimCount = 0; 101 | } else { 102 | trimCount = int(count*(trimPercent/100.)/2.); //always round down to nearest integer 103 | if (trimCount == 0) trimCount=1; 104 | } 105 | 106 | //Get all the raw data 107 | for (int x = 0; x < count; x++) { 108 | d[x] = distance(); 109 | if ((minVal > d[x])||(minVal == 0)) minVal=d[x]; 110 | if ((maxVal < d[x])||(maxVal == 0)) maxVal=d[x]; 111 | t[x] = pingTime; 112 | if ((minTime > pingTime)||(minTime == 0)) minTime = pingTime; 113 | if ((maxTime < pingTime)||(maxTime == 0)) maxTime = pingTime; 114 | avgDist += d[x]; 115 | avgTime += pingTime; 116 | delay(wait); 117 | } 118 | 119 | //No need to sort if trimCount = 0 or 1 120 | if ((count > 1)&&(trimCount > 1)){ 121 | //Insert sort routine 122 | //http://forum.arduino.cc/index.php?topic=49059.0 123 | //Sort distances 124 | for (int i = 1; i < count; ++i){ 125 | float temp = d[i]; 126 | int k; 127 | for (k = i - 1; (k >= 0) && (temp < d[k]); k--){ 128 | d[k + 1] = d[k]; 129 | } 130 | d[k + 1] = temp; 131 | } 132 | //sort ping times 133 | for (int i = 1; i < count; ++i){ 134 | float temp = t[i]; 135 | int k; 136 | for (k = i - 1; (k >= 0) && (temp < t[k]); k--){ 137 | t[k + 1] = t[k]; 138 | } 139 | t[k + 1] = temp; 140 | } 141 | } 142 | 143 | if (trimCount == 1){ // substract highest and lowest values 144 | avgDist -= (maxVal + minVal); 145 | avgTime -= (maxTime + minTime); 146 | count -= 2; 147 | }else if (trimCount > 1){ //subtract the highest and lowest points 148 | //subtract the lowest data points 149 | for (int i = 0; i < trimCount; i++) { 150 | avgDist -= d[i]; 151 | avgTime -= t[i]; 152 | } 153 | //subtract the highest data points 154 | for (int i = count-1; i > (count-1-trimCount); i--){ 155 | avgDist -= d[i]; 156 | avgTime -= t[i]; 157 | } 158 | count -= trimCount*2; //revise count less the upper and lower trimcounts 159 | } //Else assume trimCount == 0 160 | // calculate average 161 | avgDist /= count; 162 | avgTime /= count; 163 | pingTimeAvg = avgTime; //Set global value pingTimeAvg 164 | return avgDist; 165 | } 166 | 167 | /* ******************************************************* 168 | * Void Loop 169 | ********************************************************* */ 170 | void loop(){ 171 | unsigned int timeValue; //The system time 172 | 173 | float answer = distance(); 174 | Serial.println("Single shot functions"); 175 | Serial.print(" Distance = "); 176 | Serial.print(answer); //in centimeters 177 | Serial.println(" cm"); 178 | answer /= 2.54; 179 | Serial.print(" Distance = "); 180 | Serial.print(answer); //in inches 181 | Serial.println(" inches"); 182 | 183 | Serial.print(" Single round trip time "); 184 | Serial.print(pingTime); 185 | Serial.println(" uSeconds"); 186 | Serial.println(""); 187 | delay(25); 188 | //Find a distance average with a trim mean of 20 percent 189 | timeValue = millis(); 190 | answer = distanceAvg(2, 20, 20); 191 | timeValue = millis() - timeValue; 192 | Serial.println("Average functions:"); 193 | Serial.print(" Distance = "); 194 | Serial.print(answer); 195 | Serial.println(" cm"); 196 | answer /= 2.54; 197 | Serial.print(" Distance = "); 198 | Serial.print(answer); //in inches 199 | Serial.println(" inches"); 200 | Serial.print(" Average round trip time is "); 201 | Serial.println(pingTimeAvg); 202 | Serial.println(""); 203 | Serial.print("It took "); 204 | Serial.print(timeValue); 205 | Serial.println(" milliseconds to complete"); 206 | Serial.println("function distance average"); 207 | Serial.println(""); 208 | delay(2000); 209 | } 210 | 211 | -------------------------------------------------------------------------------- /Lesson 10 - Ultrasonic Sensor Module/UltrasonicDistanceLCD/UltrasonicDistanceLCD.ino: -------------------------------------------------------------------------------- 1 | /*Ultrasonic Distance LCD - using the HC-SR04 Ultrasonic Sensor Module with LCD 2 | * By Ricardo Moreno 3 | * 02/13/208 4 | * 5 | * Using the Ultrasonic Sensor without a Library 6 | * 7 | * Inspired by: 8 | * LESSON 17: Measure Speed of Sound with Arduino and Ultrasonic Sensor 9 | * https://www.youtube.com/watch?v=eaHRHQ5Ca_U 10 | * 11 | * Lesson 18: Measure Distance with Arduino and Ultrasonic Sensor by Paul McWhorter 12 | * https://www.youtube.com/watch?v=rTM5gZxBPmY 13 | * 14 | * Speed of sound 15 | * changes with with temperature 16 | * at 68 degrees F (20 degrees C) 17 | * 741 Miles per hour 18 | * 1087 feet per sec 19 | * 343.2 meters per second 20 | * 776.5 Miles per Hour (Mph) @ 77 degrees F - Paul McWhorter 21 | * 345.2944 meters per second @ 73 degrees F 22 | * Formula for speed of sound with temperature change: 23 | * sos = 331.5*sqrt(1+C/273.15) - in meters per second - C is degrees C 24 | */ 25 | /* ****************** INCLUDE LIBRARIES ********************** */ 26 | #include 27 | 28 | /* ******************* GLOBAL CONSTANTS ********************** */ 29 | //Initialize library with LCD screen 30 | // LiquidCrystal(rs, enable, d4, d5, d6, d7) 31 | // or 32 | // LiquidCrystal(rs, rw, enable, d4, d5, d6, d7) 33 | LiquidCrystal lcd(11, 10, 9, 6, 5, 4, 3); //instantiates the LiquiCrystal Object class to variable lcd 34 | 35 | // HC-SR04 module pins 36 | const int triggerPin = 12; 37 | const int echoPin = 13; 38 | 39 | //Button 40 | const int buttonPin = 2; 41 | 42 | /* ******************* GLOBAL VARIABLES ********************** */ 43 | //float speedOfSound = 343.2; //Meters per second @ 20C or 68F 44 | float speedOfSound = 346.9210755; //Meters per second @ 67F 45 | float conversionFactor = .0001; //conversion factor for meters to cm & uSec to Sec 46 | unsigned int pingTime = 0; //The time single round trip time - avail after call to distance 47 | unsigned int pingTimeAvg = 0; //The average round trip time - avail after call to distanceAvg 48 | volatile bool buttonState = false; //Keeps track of the button state 49 | 50 | /* ******************************************************* 51 | * Setup 52 | ********************************************************* */ 53 | void setup() { 54 | lcd.begin(16, 2); //16 characters and two lines 55 | pinMode(triggerPin,OUTPUT); 56 | pinMode(echoPin,INPUT); //Set echo pin as input 57 | pinMode(buttonPin,INPUT_PULLUP); //Set button pin as input with pullup resistors 58 | //Attach to interrupt 0 on pin 2 59 | attachInterrupt(digitalPinToInterrupt(buttonPin), Button_isr, CHANGE); 60 | Serial.begin(9600); //Enable the Serial Monitor 61 | lcd.print(" Distance Time"); //prints the line of text 62 | lcd.setCursor(0,1); //moves the cursor to the next line 63 | lcd.print(" 0.0cm 0000us"); //prints second line of text 64 | } 65 | 66 | /* ******************************************************* 67 | * Functions 68 | ********************************************************* */ 69 | float distance(){ 70 | /* distance returns a float value in centimeters 71 | * Parameters: none 72 | */ 73 | float dist = 0.0; 74 | 75 | digitalWrite(triggerPin, LOW); //Set the trigger pin low 76 | delayMicroseconds(5); //pause to let signal settle 77 | digitalWrite(triggerPin, HIGH); 78 | delayMicroseconds(12); //pause HIGH state 79 | digitalWrite(triggerPin, LOW); //Bring trigger down low 80 | //Change the global variable pingtime 81 | pingTime = pulseIn(echoPin, HIGH, 18000);//Measure ping time at echo pin in microseconds 82 | //timeout time in microseconds max about 3 meters 83 | //distance = speed of sound (meters per second) * 1000cm/meter * ping time/2 (uSeconds) * 1sec/1000000uSec 84 | dist = speedOfSound * conversionFactor * pingTime/2; //convert the target distance to cm 85 | return dist; 86 | } 87 | 88 | float distanceAvg(unsigned int wait=1, unsigned int pings=5, unsigned int trimPercent=0){ 89 | /* distanceAvg returns a float value in centimeters 90 | * Parameters: 91 | * [optional]wait - the time between distance checks in milliseconds, 92 | * default value is 1 93 | * [optional]pings - the number of distance checks, default value is 5 94 | * [optional]trimPercent - this is kinda like EXCEL's TRIMMEAN function 95 | * Based upon the trim percentage passed, it 96 | * determines the trim count from minimum and 97 | * maximum values: 98 | * trimCount = rounddown(pings*(trimPercent/100)/2) 99 | * default value is zero which doesn't trim outlying points 100 | */ 101 | float minVal = 0.0; 102 | unsigned long minTime = 0; 103 | float maxVal = 0.0; 104 | unsigned long maxTime = 0; 105 | float d[pings]; 106 | float t[pings]; 107 | float avgDist = 0.0; 108 | unsigned long avgTime = 0; 109 | unsigned int count = pings; 110 | unsigned int trimCount = 0; 111 | 112 | //Parameter checking 113 | if (count < 1) count = 1; 114 | if (wait < 1) wait = 1; //time in milliseconds 115 | if (trimPercent < 0) trimPercent = 0; 116 | if (trimPercent > 100) trimPercent = 100; 117 | 118 | if (trimPercent == 0){ 119 | trimCount = 0; 120 | } else { 121 | trimCount = int(count*(trimPercent/100.)/2.); //always round down to nearest integer 122 | if (trimCount == 0) trimCount=1; 123 | } 124 | 125 | //Get all the raw data 126 | for (int x = 0; x < count; x++) { 127 | d[x] = distance(); 128 | if ((minVal > d[x])||(minVal == 0)) minVal=d[x]; 129 | if ((maxVal < d[x])||(maxVal == 0)) maxVal=d[x]; 130 | t[x] = pingTime; 131 | if ((minTime > pingTime)||(minTime == 0)) minTime = pingTime; 132 | if ((maxTime < pingTime)||(maxTime == 0)) maxTime = pingTime; 133 | avgDist += d[x]; 134 | avgTime += pingTime; 135 | delay(wait); 136 | } 137 | 138 | //No need to sort if trimCount = 0 or 1 139 | if ((count > 1)&&(trimCount > 1)){ 140 | //Insert sort routine 141 | //http://forum.arduino.cc/index.php?topic=49059.0 142 | //Sort distances 143 | for (int i = 1; i < count; ++i){ 144 | float temp = d[i]; 145 | int k; 146 | for (k = i - 1; (k >= 0) && (temp < d[k]); k--){ 147 | d[k + 1] = d[k]; 148 | } 149 | d[k + 1] = temp; 150 | } 151 | //sort ping times 152 | for (int i = 1; i < count; ++i){ 153 | float temp = t[i]; 154 | int k; 155 | for (k = i - 1; (k >= 0) && (temp < t[k]); k--){ 156 | t[k + 1] = t[k]; 157 | } 158 | t[k + 1] = temp; 159 | } 160 | } 161 | 162 | if (trimCount == 1){ // substract highest and lowest values 163 | avgDist -= (maxVal + minVal); 164 | avgTime -= (maxTime + minTime); 165 | count -= 2; 166 | }else if (trimCount > 1){ //subtract the highest and lowest points 167 | //subtract the lowest data points 168 | for (int i = 0; i < trimCount; i++) { 169 | avgDist -= d[i]; 170 | avgTime -= t[i]; 171 | } 172 | //subtract the highest data points 173 | for (int i = count-1; i > (count-1-trimCount); i--){ 174 | avgDist -= d[i]; 175 | avgTime -= t[i]; 176 | } 177 | count -= trimCount*2; //revise count less the upper and lower trimcounts 178 | } //Else assume trimCount == 0 179 | // calculate average 180 | avgDist /= count; 181 | avgTime /= count; 182 | pingTimeAvg = avgTime; //Set global value pingTimeAvg 183 | return avgDist; 184 | } 185 | 186 | void LCDshow(float distance1=0.0, int time1=0000){ 187 | lcd.clear(); 188 | lcd.setCursor(0,0); 189 | if (buttonState){ 190 | //Average 191 | lcd.print(" AvgDist AvgT"); //prints the line of text 192 | } else { 193 | //single shot 194 | lcd.print(" Distance Time"); //prints the line of text 195 | } 196 | lcd.setCursor(0,1); //moves the cursor to the next line 197 | int lenValue = 6-String(distance1,2).length(); 198 | lcd.setCursor(lenValue,1); 199 | lcd.print(distance1); 200 | //lcd.setCursor(7,1); 201 | lcd.print("cm"); 202 | lcd.setCursor(10,1); 203 | lcd.print(time1); 204 | lcd.print("us"); 205 | //lcd.print(" 0.0 0000"); //prints second line of text 206 | } 207 | 208 | void Button_isr(){ 209 | // Button Interrupt Service Routine using an interrupt 210 | //Serial.println("button press"); 211 | boolean current = digitalRead(buttonPin); 212 | if(current != HIGH){ 213 | delay(5); //5 milliseconds 214 | current = digitalRead(buttonPin); 215 | } 216 | if(current == LOW) buttonState = !buttonState; 217 | } 218 | 219 | /* ******************************************************* 220 | * Void Loop 221 | ********************************************************* */ 222 | void loop(){ 223 | float answer; 224 | unsigned int timeValue; //The system time 225 | 226 | if (!buttonState){ 227 | answer = distance(); 228 | LCDshow(answer,pingTime); 229 | Serial.println("Single shot functions"); 230 | Serial.println(" Distance Time "); 231 | Serial.print(answer); //in centimeters 232 | Serial.print(" cm OR "); 233 | answer /= 2.54; 234 | Serial.print(answer); //in inches 235 | Serial.print(" inches "); 236 | Serial.print(pingTime); 237 | Serial.println(" uSeconds"); 238 | Serial.println(""); 239 | } else { 240 | //Find a distance average with a trim mean of 20 percent 241 | timeValue = millis(); 242 | answer = distanceAvg(2, 20, 20); 243 | timeValue = millis() - timeValue; 244 | LCDshow(answer,pingTimeAvg); 245 | Serial.println("Average functions:"); 246 | Serial.println(" AvgDistance AvgTime "); 247 | Serial.print(answer); 248 | Serial.print(" cm OR "); 249 | answer /= 2.54; 250 | Serial.print(answer); //in inches 251 | Serial.print(" inches "); 252 | Serial.print(pingTimeAvg); 253 | Serial.println(" uSeconds"); 254 | Serial.print("(distance average took "); 255 | Serial.print(timeValue); 256 | Serial.println(" msec to complete)"); 257 | Serial.println(""); 258 | } 259 | delay(1000); 260 | } 261 | 262 | -------------------------------------------------------------------------------- /Lesson 10 - Ultrasonic Sensor Module/UltrasonicSensorLCD.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 10 - Ultrasonic Sensor Module/UltrasonicSensorLCD.fzz -------------------------------------------------------------------------------- /Lesson 10 - Ultrasonic Sensor Module/UltrasonicSensorLCD_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 10 - Ultrasonic Sensor Module/UltrasonicSensorLCD_bb.png -------------------------------------------------------------------------------- /Lesson 10 - Ultrasonic Sensor Module/UltrasonicSensorLCD_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 10 - Ultrasonic Sensor Module/UltrasonicSensorLCD_schem.png -------------------------------------------------------------------------------- /Lesson 10 - Ultrasonic Sensor Module/mySR04_Example/mySR04_Example.ino: -------------------------------------------------------------------------------- 1 | //www.elegoo.com 2 | //2016.12.08 3 | #include "SR04.h" 4 | #define TRIG_PIN 12 5 | #define ECHO_PIN 11 6 | SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN); 7 | float a; 8 | 9 | void setup() { 10 | Serial.begin(9600); 11 | delay(1000); 12 | } 13 | 14 | void loop() { 15 | long pingDuration; 16 | 17 | a=sr04.Distance(); 18 | pingDuration = sr04.pingTime(); 19 | Serial.print(a); 20 | Serial.println("cm"); 21 | Serial.print(pingDuration); 22 | Serial.println(" round trip in microseconds"); 23 | delay(1000); 24 | } 25 | -------------------------------------------------------------------------------- /Lesson 11 - Keypad Membrane Switch Module/Analog_keypad/Analog_keypad.ino: -------------------------------------------------------------------------------- 1 | /*Analog Keypad - using the Membrane Switch Module 2 | * By Ricardo Moreno 3 | * 02/13/208 4 | * 5 | * Using the Membrane Switch Module without a Library 6 | * and one analog pin 7 | * 8 | * Inspired by: 9 | * HariFun #143 - How to read a 4x4 keypad using just one Arduino pin! 10 | * https://www.youtube.com/watch?v=G14tREsVqz0 11 | */ 12 | /* ******************* GLOBAL CONSTANTS ********************** */ 13 | const int analogPin = A0; //Analog pin that we are connecting to 14 | 15 | /* ******************* GLOBAL VARIABLES ********************** */ 16 | //Analog values for various resistor ladder values 17 | int analogValues[] = {0,68,128,181, 18 | 220,263,301,336, 19 | 362,391,418,443, 20 | 461,483,502,520}; 21 | 22 | //Keypad character values, Row0 through Row3 23 | //char* keypadButton[] = {"1","2","3","A", 24 | // "4","5","6","B", 25 | // "7","8","9","C", 26 | // "*","0","#","D"}; 27 | char keypadButton[] = "123A456B789C*0#D"; 28 | 29 | int analogValuesSize; 30 | 31 | /* ******************************************************* 32 | * Setup 33 | ********************************************************* */ 34 | void setup(){ 35 | // setup code: 36 | Serial.begin(9600); 37 | analogValuesSize = sizeof(analogValues)/sizeof(int); //Get the array size 38 | } 39 | 40 | /* ******************************************************* 41 | * Void Loop 42 | ********************************************************* */ 43 | void loop(){ 44 | // main code: 45 | int value = analogRead(analogPin); //get analog value 46 | 47 | if (value<1000){ analogKeyPress(value);} //if the value is something other than 1023 48 | // run analogKeyPress subroutine 49 | } 50 | 51 | /* ******************************************************* 52 | * Functions 53 | ********************************************************* */ 54 | 55 | int debounce(int last){ 56 | /* function debounce - button debouncing routine. Double-checks the button press to value 57 | * Parameter: 58 | * last - what the initial value was 59 | */ 60 | //Local Variable 61 | delay(10); //Small delay 62 | int current = analogRead(analogPin); //get latest analog value 63 | 64 | if(abs(current - last) > 5){ //if current >> last then get a new value 65 | delay(5); //5 milliseconds 66 | current = analogRead(analogPin); 67 | } 68 | return current; //Return analog value 69 | } 70 | 71 | void analogKeyPress(int value){ 72 | /* subroutine analogKeyPress - Sends the keypressed to the serial monitor 73 | * Parameter: 74 | * value - passed analog read value 75 | */ 76 | value = debounce(value); //Call Debounce routine and get final value 77 | for (int i = 0; i < analogValuesSize; i++){ //Search through analogValues to get keypad pressed 78 | if (abs(value - analogValues[i]) < 5){ 79 | Serial.println(keypadButton[i]); //Send keypad character to Serial Monitor 80 | //Serial.println(value); 81 | 82 | while(analogRead(analogPin) < 1000){delay(100);} //Wait until keypad button is released 83 | } 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /Lesson 11 - Keypad Membrane Switch Module/Keypad_4x4_1analogPin.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 11 - Keypad Membrane Switch Module/Keypad_4x4_1analogPin.fzz -------------------------------------------------------------------------------- /Lesson 11 - Keypad Membrane Switch Module/Keypad_4x4_1analogPin_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 11 - Keypad Membrane Switch Module/Keypad_4x4_1analogPin_bb.png -------------------------------------------------------------------------------- /Lesson 11 - Keypad Membrane Switch Module/Keypad_4x4_1analogPin_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 11 - Keypad Membrane Switch Module/Keypad_4x4_1analogPin_schem.png -------------------------------------------------------------------------------- /Lesson 11 - Keypad Membrane Switch Module/Ladder.xlsm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 11 - Keypad Membrane Switch Module/Ladder.xlsm -------------------------------------------------------------------------------- /Lesson 11 - Keypad Membrane Switch Module/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 11 - Keypad Membrane Switch Module/README.md -------------------------------------------------------------------------------- /Lesson 12 - DHT11/DHT11_Decimal/DHT11_Decimal.ino: -------------------------------------------------------------------------------- 1 | /*DHT11 Temperature and Humidity Sensor with Decimal values 2 | * By Ricardo Moreno 3 | * 02/13/208 4 | * 5 | * Note: DHT11 does not return the decimal value 6 | * DHT21 and DHT22 does return the decimal value 7 | * 8 | * Original by 9 | * www.elegoo.com 10 | * 2016.12.9 11 | * 12 | */ 13 | /* ****************** INCLUDE LIBRARIES ********************** */ 14 | #include 15 | 16 | // for DHT11, 17 | // VCC: 3.3V through 5.2V 18 | // GND: GND 19 | // DATA: 2 for example 20 | /* ******************* GLOBAL CONSTANTS ********************** */ 21 | // DHT11 data pin 22 | const int pinDHT11 = 2; 23 | SimpleDHT11 dht11; //instantiates the SimpleDHT11 Object class to variable dht11 24 | 25 | /* ******************************************************* 26 | * Setup 27 | ********************************************************* */ 28 | void setup() { 29 | Serial.begin(9600); 30 | } 31 | 32 | /* ******************************************************* 33 | * Void Loop 34 | ********************************************************* */ 35 | void loop() { 36 | // start working... 37 | Serial.println("================================="); 38 | Serial.println("Sample DHT11..."); 39 | 40 | // read with raw sample data. 41 | //Local variables 42 | float temperatureC = 0.0; 43 | float temperatureF = 0.0; 44 | float humidity = 0.0; 45 | //Local data array 46 | byte data[40] = {0}; 47 | if (dht11.read2(pinDHT11, &temperatureC, &humidity, data)) { 48 | Serial.print("Read DHT11 failed"); 49 | return; 50 | } 51 | 52 | Serial.print("Sample RAW Bits: "); 53 | for (int i = 0; i < 40; i++) { 54 | Serial.print((int)data[i]); 55 | if (i > 0 && ((i + 1) % 4) == 0) { 56 | Serial.print(' '); 57 | } 58 | } 59 | Serial.println(""); 60 | //°F = °C x 9/5 + 32. 61 | temperatureF = temperatureC * 9.0/5.0 + 32.0; 62 | Serial.print("Sample OK: "); 63 | Serial.print(temperatureC); Serial.print("°C, "); 64 | Serial.print(temperatureF); Serial.print("°F, "); 65 | Serial.print(humidity); Serial.println("%"); 66 | 67 | // DHT11 sampling rate is 1HZ. 68 | delay(1000); 69 | } 70 | -------------------------------------------------------------------------------- /Lesson 12 - DHT11/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 12 - DHT11/README.md -------------------------------------------------------------------------------- /Lesson 13 - Analog Joystick Module/Analog_Joystick_OLEDcursor/Analog_Joystick_OLEDcursor.ino: -------------------------------------------------------------------------------- 1 | /* Graphic crosshairs with analog joystick 2 | * by Ricardo Moreno 3 | * 03/15/2018 4 | * 5 | */ 6 | /* ****************** INCLUDE LIBRARIES ********************** */ 7 | #include 8 | #include // ToneAC works on pins 9 and 10 9 | 10 | /* ******************* GLOBAL CONSTANTS ********************** */ 11 | // Analog Joystick 12 | const PROGMEM int X_pin = A1; // analog pin connected to X output 13 | const PROGMEM int Y_pin = A0; // analog pin connected to Y output 14 | const PROGMEM int FIRE_BUT2 = 2; // digital pin connected to switch output 15 | 16 | //Tactile switch 17 | const PROGMEM int FIRE_BUT = A2; 18 | 19 | //Passive buzzer 20 | const PROGMEM byte spkr_pos = 9; 21 | const PROGMEM byte spkr_neg = 10; 22 | 23 | // OLED Pins 24 | // A byte can hold a number up to 255 25 | const PROGMEM byte OLED_CLK = 13; //SCK system clock or SCL 26 | const PROGMEM byte OLED_MOSI = 11; //MOSI or SDA 27 | const PROGMEM byte OLED_RES = 8; //Reset 28 | const PROGMEM byte OLED_DC = 7; //Data Communication 29 | const PROGMEM byte OLED_CS = 6; //Component Select 30 | //Instantiate U8G2 object class - Plus Pins 31 | //There is only one small difference between SSD1306 and SH1106: The SH1106 controller has an internal RAM of 132x64 pixel 32 | //SSD1306 33 | //U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI oled(U8G2_R0, /* clock=*/ OLED_CLK, /* data=*/ OLED_MOSI, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 34 | //U8G2_SSD1306_128X64_NONAME_2_4W_SW_SPI oled(U8G2_R0, /* clock=*/ OLED_CLK, /* data=*/ OLED_MOSI, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 35 | //U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI oled(U8G2_R0, /* clock=*/ OLED_CLK, /* data=*/ OLED_MOSI, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 36 | //U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI oled(U8G2_R0, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 37 | //U8G2_SSD1306_128X64_NONAME_2_4W_HW_SPI oled(U8G2_R0, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 38 | //U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI oled(U8G2_R0, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 39 | //SH1106 40 | //U8G2_SH1106_128X64_NONAME_1_4W_SW_SPI oled(U8G2_R0, /* clock=*/ OLED_CLK, /* data=*/ OLED_MOSI, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 41 | //U8G2_SH1106_128X64_NONAME_2_4W_SW_SPI oled(U8G2_R0, /* clock=*/ OLED_CLK, /* data=*/ OLED_MOSI, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 42 | //U8G2_SH1106_128X64_NONAME_F_4W_SW_SPI oled(U8G2_R0, /* clock=*/ OLED_CLK, /* data=*/ OLED_MOSI, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 43 | //U8G2_SH1106_128X64_NONAME_1_4W_HW_SPI oled(U8G2_R0, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 44 | //U8G2_SH1106_128X64_NONAME_2_4W_HW_SPI oled(U8G2_R0, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 45 | U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI oled(U8G2_R0, /* cs=*/ OLED_CS, /* dc=*/ OLED_DC, /* reset=*/ OLED_RES); 46 | 47 | const int MAXSCREEN_WIDTH PROGMEM = 128; //0-127 48 | const int MAXSCREEN_HEIGHT PROGMEM = 64; //0-63 49 | const int MAXANALOG_VALUE PROGMEM = 1023; //0-1023 50 | 51 | /* ******************* GLOBAL VARIABLES ********************** */ 52 | int cursor_height = 20; 53 | int cursor_width = 20; 54 | int Xvalue = 512; 55 | int Yvalue = 512; 56 | bool Switchvalue = HIGH; 57 | 58 | /* ******************************************************* 59 | * Setup 60 | ********************************************************* */ 61 | void setup() { 62 | pinMode(FIRE_BUT2, INPUT_PULLUP); 63 | pinMode(FIRE_BUT, INPUT_PULLUP); 64 | //Serial.begin(9600); 65 | //OLED Diplay 66 | /* U8g2 Project: SSD1306 or SH1106 OLED SPI Board */ 67 | oled.begin(); 68 | oled.clear(); 69 | oled.setBitmapMode(1); 70 | } 71 | 72 | /* ******************************************************* 73 | * Void Loop 74 | ********************************************************* */ 75 | void loop() { 76 | if ((!digitalRead(FIRE_BUT))||(!digitalRead(FIRE_BUT2))){ 77 | Switchvalue = false; 78 | }else{ 79 | Switchvalue = true; 80 | } 81 | Xvalue = analogRead(X_pin); 82 | Yvalue = analogRead(Y_pin); 83 | //Serial.print("Switch: "); 84 | //Serial.print(Switchvalue); 85 | //Serial.print(" X-axis: "); 86 | //Serial.print(Xvalue); 87 | //Serial.print(" Y-axis: "); 88 | //Serial.println(Yvalue); 89 | //Serial.print("\n"); 90 | oled.clearBuffer(); 91 | draw(Xvalue, Yvalue, Switchvalue); 92 | oled.sendBuffer(); 93 | //delay(100); 94 | } 95 | 96 | /* ******************************************************* 97 | * Functions 98 | ********************************************************* */ 99 | 100 | void draw(int x, int y, bool sw){ 101 | x = map(x,MAXANALOG_VALUE,0,0,MAXSCREEN_WIDTH-1); 102 | y = map(y,0,MAXANALOG_VALUE,0,MAXSCREEN_HEIGHT-1); 103 | //Serial.print("X = "); Serial.print(x); Serial.print(" Y = "); Serial.println(y); 104 | //oled.drawVLine(x, y-cursor_height/2, cursor_height); 105 | oled.drawVLine(x,0,MAXSCREEN_HEIGHT-1); 106 | //oled.drawHLine(x-cursor_width/2, y, cursor_width); 107 | oled.drawHLine(0, y, MAXSCREEN_WIDTH-1); 108 | if (sw){ 109 | oled.drawCircle(x, y, 10, U8G2_DRAW_ALL); 110 | } else { 111 | //toneAC(frequency, volume, length , background) 112 | toneAC(600,5,200,true); 113 | oled.drawDisc(x, y, 10, U8G2_DRAW_ALL); 114 | } 115 | } 116 | 117 | -------------------------------------------------------------------------------- /Lesson 13 - Analog Joystick Module/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 13 - Analog Joystick Module/README.md -------------------------------------------------------------------------------- /Lesson 14 - IR Receiver Module/IR_Receiver_Module/IR_Receiver_Module.ino: -------------------------------------------------------------------------------- 1 | //www.elegoo.com 2 | //2016.12.9 3 | 4 | #include "IRremote.h" 5 | 6 | /*-----( Global Constants )-----*/ 7 | const int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11 8 | 9 | /*-----( Declare objects )-----*/ 10 | IRrecv irrecv(receiver); // create instance of 'irrecv' 11 | decode_results results; // create instance of 'decode_results' 12 | 13 | /*-----( Function )-----*/ 14 | void translateIR() { // takes action based on IR code received 15 | // describing Remote IR codes 16 | 17 | switch(results.value){ 18 | case 0xFFA25D: Serial.println("POWER"); break; 19 | case 0xFFE21D: Serial.println("FUNC/STOP"); break; 20 | case 0xFF629D: Serial.println("VOL+"); break; 21 | case 0xFF22DD: Serial.println("FAST BACK"); break; 22 | case 0xFF02FD: Serial.println("PAUSE"); break; 23 | case 0xFFC23D: Serial.println("FAST FORWARD"); break; 24 | case 0xFFE01F: Serial.println("DOWN"); break; 25 | case 0xFFA857: Serial.println("VOL-"); break; 26 | case 0xFF906F: Serial.println("UP"); break; 27 | case 0xFF9867: Serial.println("EQ"); break; 28 | case 0xFFB04F: Serial.println("ST/REPT"); break; 29 | case 0xFF6897: Serial.println("0"); break; 30 | case 0xFF30CF: Serial.println("1"); break; 31 | case 0xFF18E7: Serial.println("2"); break; 32 | case 0xFF7A85: Serial.println("3"); break; 33 | case 0xFF10EF: Serial.println("4"); break; 34 | case 0xFF38C7: Serial.println("5"); break; 35 | case 0xFF5AA5: Serial.println("6"); break; 36 | case 0xFF42BD: Serial.println("7"); break; 37 | case 0xFF4AB5: Serial.println("8"); break; 38 | case 0xFF52AD: Serial.println("9"); break; 39 | case 0xFFFFFFFF: Serial.println(" REPEAT");break; 40 | 41 | default: 42 | Serial.print(" other button "); 43 | Serial.println(results.value); 44 | 45 | }// End Case 46 | 47 | } //END translateIR 48 | 49 | void setup(){ /*----( SETUP: RUNS ONCE )----*/ 50 | Serial.begin(9600); 51 | Serial.println("IR Receiver Button Decode"); 52 | irrecv.enableIRIn(); // Start the receiver 53 | 54 | }/*--(end setup )---*/ 55 | 56 | void loop(){ /*----( LOOP: RUNS CONSTANTLY )----*/ 57 | if (irrecv.decode(&results)) // have we received an IR signal? 58 | { 59 | translateIR(); 60 | delay(500); // Do not get immediate repeat 61 | irrecv.resume(); // receive the next value 62 | } 63 | }/* --(end main loop )-- */ 64 | 65 | 66 | -------------------------------------------------------------------------------- /Lesson 14 - IR Receiver Module/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 14 - IR Receiver Module/README.md -------------------------------------------------------------------------------- /Lesson 15 - MAX7219 Module/LEDGraphicToHex.xlsm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 15 - MAX7219 Module/LEDGraphicToHex.xlsm -------------------------------------------------------------------------------- /Lesson 15 - MAX7219 Module/MyMarqueeText/MyMarqueeText.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // This sketch draw marquee text on your LED matrix using the hardware SPI driver Library by Bartosz Bielawski. 4 | // Example written 16.06.2017 by Marko Oette, www.oette.info 5 | 6 | // Define the ChipSelect pin for the led matrix (Dont use the SS or MISO pin of your Arduino!) 7 | // Other pins are arduino specific SPI pins (MOSI=DIN of the LEDMatrix and CLK) see https://www.arduino.cc/en/Reference/SPI 8 | const uint8_t LEDMATRIX_CS_PIN PROGMEM = 5; 9 | 10 | // Define LED Matrix dimensions (0-n) - eg: 32x8 = 31x7 11 | const int LEDMATRIX_WIDTH PROGMEM = 7; 12 | const int LEDMATRIX_HEIGHT PROGMEM = 7; 13 | const int LEDMATRIX_SEGMENTS PROGMEM = 1; 14 | 15 | // The LEDMatrixDriver class instance 16 | LEDMatrixDriver lmd(LEDMATRIX_SEGMENTS, LEDMATRIX_CS_PIN); 17 | 18 | void setup() { 19 | // init the display 20 | lmd.setEnabled(true); 21 | lmd.setIntensity(2); // 0 = low, 10 = high 22 | } 23 | 24 | int x=0, y=0; // start top left 25 | 26 | // This is the font definition. You can use http://gurgleapps.com/tools/matrix to create your own font or sprites. 27 | // If you like the font feel free to use it. I created it myself and donate it to the public domain. 28 | byte font[95][8] = { {0,0,0,0,0,0,0,0}, // SPACE 29 | {0x10,0x18,0x18,0x18,0x18,0x00,0x18,0x18}, // EXCL 30 | {0x28,0x28,0x08,0x00,0x00,0x00,0x00,0x00}, // QUOT 31 | {0x00,0x0a,0x7f,0x14,0x28,0xfe,0x50,0x00}, // # 32 | {0x10,0x38,0x54,0x70,0x1c,0x54,0x38,0x10}, // $ 33 | {0x00,0x60,0x66,0x08,0x10,0x66,0x06,0x00}, // % 34 | {0,0,0,0,0,0,0,0}, // & 35 | {0x00,0x10,0x18,0x18,0x08,0x00,0x00,0x00}, // ' 36 | {0x02,0x04,0x08,0x08,0x08,0x08,0x08,0x04}, // ( 37 | {0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x20}, // ) 38 | {0x00,0x10,0x54,0x38,0x10,0x38,0x54,0x10}, // * 39 | {0x00,0x08,0x08,0x08,0x7f,0x08,0x08,0x08}, // + 40 | {0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x08}, // COMMA 41 | {0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00}, // - 42 | {0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06}, // DOT 43 | {0x00,0x04,0x04,0x08,0x10,0x20,0x40,0x40}, // / 44 | {0x00,0x38,0x44,0x4c,0x54,0x64,0x44,0x38}, // 0 45 | {0x04,0x0c,0x14,0x24,0x04,0x04,0x04,0x04}, // 1 46 | {0x00,0x30,0x48,0x04,0x04,0x38,0x40,0x7c}, // 2 47 | {0x00,0x38,0x04,0x04,0x18,0x04,0x44,0x38}, // 3 48 | {0x00,0x04,0x0c,0x14,0x24,0x7e,0x04,0x04}, // 4 49 | {0x00,0x7c,0x40,0x40,0x78,0x04,0x04,0x38}, // 5 50 | {0x00,0x38,0x40,0x40,0x78,0x44,0x44,0x38}, // 6 51 | {0x00,0x7c,0x04,0x04,0x08,0x08,0x10,0x10}, // 7 52 | {0x00,0x3c,0x44,0x44,0x38,0x44,0x44,0x78}, // 8 53 | {0x00,0x38,0x44,0x44,0x3c,0x04,0x04,0x78}, // 9 54 | {0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00}, // : 55 | {0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x08}, // ; 56 | {0x00,0x10,0x20,0x40,0x80,0x40,0x20,0x10}, // < 57 | {0x00,0x00,0x7e,0x00,0x00,0xfc,0x00,0x00}, // = 58 | {0x00,0x08,0x04,0x02,0x01,0x02,0x04,0x08}, // > 59 | {0x00,0x38,0x44,0x04,0x08,0x10,0x00,0x10}, // ? 60 | {0x00,0x30,0x48,0xba,0xba,0x84,0x78,0x00}, // @ 61 | {0x00,0x1c,0x22,0x42,0x42,0x7e,0x42,0x42}, // A 62 | {0x00,0x78,0x44,0x44,0x78,0x44,0x44,0x7c}, // B 63 | {0x00,0x3c,0x44,0x40,0x40,0x40,0x44,0x7c}, // C 64 | {0x00,0x7c,0x42,0x42,0x42,0x42,0x44,0x78}, // D 65 | {0x00,0x78,0x40,0x40,0x70,0x40,0x40,0x7c}, // E 66 | {0x00,0x7c,0x40,0x40,0x78,0x40,0x40,0x40}, // F 67 | {0x00,0x3c,0x40,0x40,0x5c,0x44,0x44,0x78}, // G 68 | {0x00,0x42,0x42,0x42,0x7e,0x42,0x42,0x42}, // H 69 | {0x00,0x7c,0x10,0x10,0x10,0x10,0x10,0x7e}, // I 70 | {0x00,0x7e,0x02,0x02,0x02,0x02,0x04,0x38}, // J 71 | {0x00,0x44,0x48,0x50,0x60,0x50,0x48,0x44}, // K 72 | {0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x7c}, // L 73 | {0x00,0x82,0xc6,0xaa,0x92,0x82,0x82,0x82}, // M 74 | {0x00,0x42,0x42,0x62,0x52,0x4a,0x46,0x42}, // N 75 | {0x00,0x3c,0x42,0x42,0x42,0x42,0x44,0x38}, // O 76 | {0x00,0x78,0x44,0x44,0x48,0x70,0x40,0x40}, // P 77 | {0x00,0x3c,0x42,0x42,0x52,0x4a,0x44,0x3a}, // Q 78 | {0x00,0x78,0x44,0x44,0x78,0x50,0x48,0x44}, // R 79 | {0x00,0x38,0x40,0x40,0x38,0x04,0x04,0x78}, // S 80 | {0x00,0x7e,0x90,0x10,0x10,0x10,0x10,0x10}, // T 81 | {0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x3e}, // U 82 | {0x00,0x42,0x42,0x42,0x42,0x44,0x28,0x10}, // V 83 | {0x80,0x82,0x82,0x92,0x92,0x92,0x94,0x78}, // W 84 | {0x00,0x42,0x42,0x24,0x18,0x24,0x42,0x42}, // X 85 | {0x00,0x44,0x44,0x28,0x10,0x10,0x10,0x10}, // Y 86 | {0x00,0x7c,0x04,0x08,0x7c,0x20,0x40,0xfe}, // Z 87 | // (the font does not contain any lower case letters. you can add your own.) 88 | }; // {}, // 89 | 90 | // Marquee speed 91 | const int ANIM_DELAY PROGMEM = 100; 92 | 93 | // Marquee text 94 | //char text[] = "** LED MATRIX DEMO! ** (1234567890) ++ \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" ++ <$%/=?'.@,> --"; 95 | char text[] = "** RICK THE TECH ENTHUSIAST VIDEOS! ** (1234567890) ++ \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" ++ <$%/=?'.@,> --"; 96 | int len = strlen(text); 97 | 98 | void loop() 99 | { 100 | // Draw the text to the current position 101 | drawString(text, len, x, 0); 102 | // In case you wonder why we don't have to call lmd.clear() in every loop: The font has a opaque (black) background... 103 | 104 | // Toggle display of the new framebuffer 105 | lmd.display(); 106 | 107 | // Wait to let the human read the display 108 | delay(ANIM_DELAY); 109 | 110 | // Advance to next coordinate 111 | if( --x < len * -8 ) 112 | x = LEDMATRIX_WIDTH; 113 | } 114 | 115 | 116 | /** 117 | * This function draws a string of the given length to the given position. 118 | */ 119 | void drawString(char* text, int len, int x, int y ) 120 | { 121 | for( int idx = 0; idx < len; idx ++ ) 122 | { 123 | int c = text[idx] - 32; 124 | 125 | // stop if char is outside visible area 126 | if( x + idx * 8 > LEDMATRIX_WIDTH ) 127 | return; 128 | 129 | // only draw if char is visible 130 | if( 8 + x + idx * 8 > 0 ) 131 | drawSprite( font[c], x + idx * 8, y, 8, 8 ); 132 | } 133 | } 134 | 135 | /** 136 | * This draws a sprite to the given position using the width and height supplied (usually 8x8) 137 | */ 138 | void drawSprite( byte* sprite, int x, int y, int width, int height ) 139 | { 140 | // The mask is used to get the column bit from the sprite row 141 | byte mask = B10000000; 142 | 143 | for( int iy = 0; iy < height; iy++ ) 144 | { 145 | for( int ix = 0; ix < width; ix++ ) 146 | { 147 | lmd.setPixel(x + ix, y + iy, (bool)(sprite[iy] & mask )); 148 | 149 | // shift the mask by one pixel to the right 150 | mask = mask >> 1; 151 | } 152 | 153 | // reset column mask 154 | mask = B10000000; 155 | } 156 | } 157 | 158 | -------------------------------------------------------------------------------- /Lesson 15 - MAX7219 Module/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 15 - MAX7219 Module/README.md -------------------------------------------------------------------------------- /Lesson 16 - GY-521 Module/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 16 - GY-521 Module/README.md -------------------------------------------------------------------------------- /Lesson 17 - HC-SR501/HC-SR501_Demo/HC-SR501_Demo.ino: -------------------------------------------------------------------------------- 1 | /* *********************************************************** 2 | * HC-SR501 Motion Sensor Demonstration 3 | * Uses the HC-SR501 PIR Sensor 4 | * Modified by Ricardo Moreno 5 | * June 23, 2018 6 | * 7 | * Inspired by Elegoo Lesson 17 and DroneBot 8 | * Motion Sensor with Delay 9 | * DroneBot Workshop 2018 10 | * https://dronebotworkshop.com 11 | * 12 | * Note: Set the sensor for 3-second trigger 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * 22 | * History: 23 | * 06/23/2018 V1.0 - Initial release 24 | */ 25 | 26 | /* *********************************************************** 27 | * Global Constants * 28 | * ********************************************************* */ 29 | // Set the Arduino pins 30 | const int detectedLED = 10; // Blue LED Pin 31 | const int readyLED = 9; // Green LED Pin 32 | const int waitLED = 8; // Red LED Pin 33 | const int pirPin = 7; // Input from Motion Sensor 34 | const int BuzzerPin = 11; // Active buzzer pin 35 | 36 | //Set Detection Constants for Different States 37 | const int TRIGGERED = 2; 38 | const int READY = 1; 39 | const int WAIT = 0; 40 | 41 | //Set Constant DELAY or ON times here 42 | const int BuzzerOnTime = 500; // Active Buzzer time 43 | const int dotLength = 40; // Number of progress dots max per row 44 | const unsigned int initialDelay = 60000; // Initial startup delay 45 | const unsigned int divisor = 40000; // Period of time between progress periods 46 | /* *********************************************************** 47 | * Global Variables * 48 | * ********************************************************* */ 49 | bool BuzzerOnState = false; // Buzzer State 50 | int pirValue; // PIR Output value 51 | int pirState; // Stores the PIR State 52 | unsigned long triggeredStartTime; // Stores Start time 53 | unsigned long waitStartTime; // Stores Wait Start time - 54 | // when output pin switches from High to Low 55 | unsigned int timeDelay; // Time delay - 56 | // manually adjust time delay to 3 seconds 57 | // software recorded 58 | unsigned int waitDelay = 7000; // Wait delay is after time delay - 59 | // software adjusted 60 | 61 | /* *********************************************************** 62 | * Void Setup * 63 | * ********************************************************* */ 64 | void setup(){ 65 | Serial.begin(9600); 66 | 67 | /* Setup PinModes */ 68 | // LEDs as Outputs 69 | pinMode(detectedLED, OUTPUT); 70 | pinMode(readyLED, OUTPUT); 71 | pinMode(waitLED, OUTPUT); 72 | // Buzzer as Outputs 73 | pinMode(BuzzerPin, OUTPUT); 74 | // PIR as Input 75 | pinMode(pirPin, INPUT); 76 | 77 | /* Initial 1 Minute Delay to stabilize sensor */ 78 | Serial.println("Wait one minute to stabilize sensor"); 79 | showLEDs(WAIT); 80 | 81 | // Make progress trailing dots 82 | for (int i=0; i<= initialDelay/400; i++){ 83 | //This loop makes the trailing dots across the screen. 84 | if ((i%(dotLength-5)==0)&&(i>0)&&(i==(dotLength-5))){ 85 | //First Line 86 | Serial.println("."); 87 | } else if (((i-(dotLength-5))%dotLength==0)&&(i>(dotLength-4))){ 88 | //Lines after 89 | Serial.println("."); 90 | } else { 91 | Serial.print("."); 92 | } 93 | delay(400); 94 | } 95 | showLEDs(READY); 96 | } 97 | 98 | /* *********************************************************** 99 | * Void Loop * 100 | * ********************************************************* */ 101 | void loop(){ 102 | static int i; 103 | switch (pirState){ 104 | case READY: 105 | pirValue = digitalRead(pirPin); 106 | if (pirValue) { 107 | pirTriggered(); 108 | i=0; 109 | } 110 | break; 111 | case TRIGGERED: 112 | /* NOTE: While triggered, PIR output will remain high until 113 | time delay is passed. If repeatable trigger mode is 114 | enabled, it will reset the time delay. 115 | 116 | At this point, the Arduino cannot do anything but monitor 117 | the output 118 | */ 119 | // Make progress trailing dots 120 | if (i%divisor==0) {Serial.print(".");} 121 | 122 | //Check for Low PIR value 123 | pirValue = digitalRead(pirPin); 124 | if (!pirValue) { //times up 125 | /* Wait time begins */ 126 | waitStartTime = millis(); 127 | timeDelay = waitStartTime-triggeredStartTime; // Records the actual time delay 128 | Serial.print("timeDelay = "); Serial.print(timeDelay); Serial.println("ms"); 129 | showLEDs(WAIT); 130 | i=0; 131 | } 132 | 133 | //Check Buzzer 134 | if ((BuzzerOnState)&&((millis()-triggeredStartTime)>= BuzzerOnTime)){ 135 | BuzzerOnState = false; 136 | digitalWrite(BuzzerPin, LOW); 137 | } 138 | i++; 139 | break; 140 | case WAIT: 141 | // Make progress trailing dots 142 | if (i%divisor==0) {Serial.print(".");} 143 | 144 | // Check time > waitDelay 145 | if ((millis()-waitStartTime)>= waitDelay) { 146 | Serial.print("waitDelay = "); Serial.print(waitDelay); Serial.println("ms"); 147 | showLEDs(READY); 148 | i=0; 149 | } 150 | 151 | /* NOTE: Since PIR hardware is not controlled by the Arduino, 152 | wait delay is approximate. If early motion detection is 153 | discovered, quickly record the new value and switch states 154 | */ 155 | pirValue = digitalRead(pirPin); 156 | if (pirValue) { 157 | // Autocorrection Routine: 158 | // record new wait delay and jump to Triggered State 159 | waitDelay = millis()-waitStartTime; 160 | Serial.println("PreTriggered!"); 161 | Serial.print("Autocorrecting waitDelay = "); Serial.print(waitDelay); Serial.println("ms"); 162 | pirTriggered(); //Turn on Triggered LED and switch to Triggered State 163 | i=0; 164 | } 165 | i++; 166 | break; 167 | default: 168 | // do nothing 169 | break; 170 | } 171 | } 172 | 173 | /* *********************************************************** 174 | * Functions * 175 | * ********************************************************* */ 176 | void pirTriggered(){ 177 | /* This Subroutine switches on all the things that need 178 | * to happen during a triggered event. 179 | */ 180 | triggeredStartTime = millis(); // Record Triggered Start Time 181 | showLEDs(TRIGGERED); // Show Triggered LED 182 | digitalWrite(BuzzerPin, HIGH); // Enable Buzzer 183 | BuzzerOnState = true; // Enable Buzzer State 184 | Serial.print("Measuring Delay."); 185 | } 186 | 187 | void showLEDs(int value){ 188 | pirState = value; 189 | switch (value){ 190 | case WAIT: //WAIT 191 | Serial.print("Wait"); // to be followed by progress dots 192 | digitalWrite(detectedLED, LOW); 193 | digitalWrite(readyLED, LOW); 194 | digitalWrite(waitLED, HIGH); 195 | break; 196 | case READY: //READY 197 | Serial.println("Ready"); 198 | digitalWrite(detectedLED, LOW); 199 | digitalWrite(readyLED, HIGH); 200 | digitalWrite(waitLED, LOW); 201 | break; 202 | case TRIGGERED: //TRIGGERED 203 | Serial.println("Triggered!"); 204 | digitalWrite(detectedLED, HIGH); 205 | digitalWrite(readyLED, LOW); 206 | digitalWrite(waitLED, LOW); 207 | break; 208 | default: 209 | // Maybe add error code here 210 | // do nothing 211 | break; 212 | } 213 | } 214 | 215 | -------------------------------------------------------------------------------- /Lesson 17 - HC-SR501/HC-SR501_plus.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 17 - HC-SR501/HC-SR501_plus.fzz -------------------------------------------------------------------------------- /Lesson 17 - HC-SR501/HC-SR501_plus_bb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 17 - HC-SR501/HC-SR501_plus_bb.jpg -------------------------------------------------------------------------------- /Lesson 17 - HC-SR501/HC-SR501_plus_schem.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 17 - HC-SR501/HC-SR501_plus_schem.jpg -------------------------------------------------------------------------------- /Lesson 17 - HC-SR501/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 17 - HC-SR501/README.md -------------------------------------------------------------------------------- /Lesson 18 - Water Level Detection Sensor Module/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 18 - Water Level Detection Sensor Module/README.md -------------------------------------------------------------------------------- /Lesson 18 - Water Level Detection Sensor Module/Water_level/Water_level.ino: -------------------------------------------------------------------------------- 1 | /* *********************************************************** 2 | * Water Level 3 | * Uses the Water Level Detection Sensor Module 4 | * Modified by Ricardo Moreno 5 | * July 11, 2018 6 | * 7 | * Original sketch by: 8 | * www.elegoo.com 9 | * 2016.12.9 10 | */ 11 | 12 | /* *********************************************************** 13 | * Global Constants * 14 | * ********************************************************* */ 15 | const int sensorPin = A0; // using alias for analog pin 0 16 | // analog alias A0-A5 input pins = D14-D19 17 | bool tapWater = true; // Boolean if using plain tap water 18 | 19 | /* *********************************************************** 20 | * Global Variables * 21 | * ********************************************************* */ 22 | int HistoryValue = 0; 23 | //char printBuffer[20]; // Make sure to adjust array value if you change the string 24 | //char printBuffer[30]; // Make sure to adjust array value if you change the string 25 | char printBuffer[45]; // Make sure to adjust array value if you change the string 26 | String analogPin; 27 | 28 | /* *********************************************************** 29 | * Void Setup * 30 | * ********************************************************* */ 31 | void setup() 32 | { 33 | Serial.begin(9600); 34 | analogPin = analogPinConverter(sensorPin); 35 | } 36 | 37 | int levelConverter(int sensorValue, bool isCleanWater = true){ 38 | int percentage; 39 | static int maxValue = 350; 40 | 41 | if (isCleanWater){ 42 | percentage = map(sensorValue, 0, maxValue, 0, 100); 43 | if (percentage > 100) { 44 | maxValue = sensorValue; 45 | percentage = 100; 46 | } 47 | }else{ 48 | percentage = map(sensorValue, 0, 1023, 0, 100); 49 | } 50 | return percentage; 51 | } 52 | 53 | /* *********************************************************** 54 | * Void Loop * 55 | * ********************************************************* */ 56 | void loop() 57 | { 58 | int currentValue = analogRead(sensorPin); // get sensorPin analog value 59 | int diffValue = HistoryValue - currentValue; 60 | if((abs(diffValue) >= 10)||((currentValue == 0)&&(HistoryValue != 0))) 61 | { 62 | int percentValue = levelConverter(currentValue, tapWater); 63 | //[original] sprintf(printBuffer,"ADC%d level is %d\n",adc_id, value); 64 | // sprintf(printBuffer,"PIN %03d level is %04d\n", sensorPin, currentValue); 65 | // sprintf(printBuffer,"PIN %s level is %04d)\n", analogPin.c_str(), currentValue); 66 | sprintf(printBuffer,"PIN %s level is %03d%% (raw value is %04d)\n", analogPin.c_str(), percentValue, currentValue); 67 | Serial.print(printBuffer); 68 | HistoryValue = currentValue; 69 | } 70 | } 71 | 72 | String analogPinConverter(int value){ 73 | String analogPinValue; 74 | 75 | switch(value){ 76 | case 14: // D14 = A0 77 | analogPinValue = "A0"; 78 | break; 79 | case 15: // D15 = A1 80 | analogPinValue = "A1"; 81 | break; 82 | case 16: // D16 = A2 83 | analogPinValue = "A2"; 84 | break; 85 | case 17: // D17 = A3 86 | analogPinValue = "A3"; 87 | break; 88 | case 18: // D18 = A4 89 | analogPinValue = "A4"; 90 | break; 91 | case 19: // D19 = A5 92 | analogPinValue = "A5"; 93 | break; 94 | default: 95 | analogPinValue = "Pin Error"; 96 | break; 97 | } 98 | return analogPinValue; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /Lesson 19 - Real Time Clock Module/AT24C32N datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 19 - Real Time Clock Module/AT24C32N datasheet.pdf -------------------------------------------------------------------------------- /Lesson 19 - Real Time Clock Module/DS3231 schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 19 - Real Time Clock Module/DS3231 schematic.png -------------------------------------------------------------------------------- /Lesson 19 - Real Time Clock Module/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 19 - Real Time Clock Module/README.md -------------------------------------------------------------------------------- /Lesson 19 - Real Time Clock Module/RTC_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 19 - Real Time Clock Module/RTC_bb.png -------------------------------------------------------------------------------- /Lesson 19 - Real Time Clock Module/RTC_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 19 - Real Time Clock Module/RTC_schem.png -------------------------------------------------------------------------------- /Lesson 19 - Real Time Clock Module/SimpleAlarmClock-1.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 19 - Real Time Clock Module/SimpleAlarmClock-1.0.zip -------------------------------------------------------------------------------- /Lesson 19 - Real Time Clock Module/Thick Film Chip Network Resistors.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 19 - Real Time Clock Module/Thick Film Chip Network Resistors.pdf -------------------------------------------------------------------------------- /Lesson 20 - Sound Sensor Module/KY-038_schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 20 - Sound Sensor Module/KY-038_schematic.png -------------------------------------------------------------------------------- /Lesson 20 - Sound Sensor Module/Lesson20.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 20 - Sound Sensor Module/Lesson20.fzz -------------------------------------------------------------------------------- /Lesson 20 - Sound Sensor Module/Lesson20_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 20 - Sound Sensor Module/Lesson20_bb.png -------------------------------------------------------------------------------- /Lesson 20 - Sound Sensor Module/Lesson20_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 20 - Sound Sensor Module/Lesson20_schem.png -------------------------------------------------------------------------------- /Lesson 20 - Sound Sensor Module/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 20 - Sound Sensor Module/README.md -------------------------------------------------------------------------------- /Lesson 20 - Sound Sensor Module/SoundSensor.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 20 - Sound Sensor Module/SoundSensor.fzz -------------------------------------------------------------------------------- /Lesson 20 - Sound Sensor Module/SoundSensor_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 20 - Sound Sensor Module/SoundSensor_bb.png -------------------------------------------------------------------------------- /Lesson 20 - Sound Sensor Module/SoundSensor_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 20 - Sound Sensor Module/SoundSensor_schem.png -------------------------------------------------------------------------------- /Lesson 21 - RC522 RFID Module/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 21 - RC522 RFID Module/README.md -------------------------------------------------------------------------------- /Lesson 21 - RC522 RFID Module/RFID_module/RFID_module.ino: -------------------------------------------------------------------------------- 1 | /* *********************************************************** 2 | * RFID_module sketch - v1.0 3 | * Uses the RFC522 RFID Module and tags 4 | * Uses the SPI.h library 5 | * Uses the MFRC522.h library 6 | * 7 | * Inspired by Elegoo Lesson 21, and by Dejan Nedelkovski 8 | * www.HowToMechatronics.com 9 | * Arduino Door Lock Access Control Project 10 | * https://howtomechatronics.com/tutorials/arduino/rfid-works-make-arduino-based-rfid-door-lock/ 11 | * 12 | * Description: 13 | * This sketch illustrates some of the functionality of the 14 | * RFC522 RFID module and tags. Set the card tag as a Master 15 | * and use it to authorize the keychain tag. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 18 | * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 19 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 20 | * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 21 | * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 22 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | * History: 27 | * 01/20/2019 v1.0 - Initial release 28 | * 29 | * @author Ricardo Moreno 30 | ********************************************************** */ 31 | 32 | /* *********************************************************** 33 | * Libraries * 34 | * ********************************************************* */ 35 | #include 36 | #include 37 | 38 | /* *********************************************************** 39 | * Global Constants * 40 | * Hardware Definitions * 41 | * ********************************************************* */ 42 | /* Typical pin layout used: 43 | * ----------------------------------------------------------------------------------------- 44 | * MFRC522 Arduino Arduino Arduino Arduino Arduino 45 | * Reader/PCD Uno Mega Nano v3 Leonardo/Micro Pro Micro 46 | * Signal Pin Pin Pin Pin Pin Pin 47 | * ----------------------------------------------------------------------------------------- 48 | * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST 49 | * SPI SS SDA(SS) 10 53 D10 10 10 50 | * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 51 | * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 52 | * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 53 | */ 54 | // Other hardware pins 55 | const byte rstPin = 9; // Reset pin 56 | const byte ssPin = 10; // Slave Select pin 57 | 58 | // Instantiate MFRC522 object class 59 | MFRC522 rfidReader(ssPin, rstPin); 60 | 61 | // Other Global Constants 62 | const long timeout = 30000; // Timeout in ms 63 | 64 | /* *********************************************************** 65 | * Global Variables * 66 | * ********************************************************* */ 67 | char* myTags[100] = {}; 68 | int tagsCount = 0; 69 | String tagID = ""; 70 | 71 | bool readRFID(long _timeout=timeout, bool useTimeout=false){ 72 | /* readRFID will continuously check the RFID reader for the presence of 73 | * a tag from and will attempt to get tag IDs. Updates global value 74 | * tagID via getTagID function. 75 | * Parameters: 76 | * _timeout - [optional] the length of time before functio gives up 77 | * default value = global timout value 78 | * useTimeout - [optional] boolean to enforce timout period or wait 79 | * indefinately. Default value = false. 80 | * Returns: 81 | * true - successfully reads tag ID 82 | * false - unsuccessful in reading the tag ID 83 | */ 84 | bool successRead = false; 85 | 86 | unsigned long startTime = millis(); 87 | unsigned long currentTime = startTime; 88 | // S'U'+S'T' 89 | // T = (currentTime-startTime) > timeout 90 | // T' = (currentTime-startTime) < timeout 91 | while (((successRead==false)&&(useTimeout==false)) || ((successRead==false)&&((currentTime - startTime) < _timeout))) { 92 | if (isTagPresent() == true){ successRead = getTagID(); } 93 | currentTime = millis(); 94 | } 95 | return successRead; 96 | } 97 | 98 | /* *********************************************************** 99 | * Void Setup * 100 | * ********************************************************* */ 101 | void setup() { 102 | // Initiating 103 | Serial.begin(9600); // Start the serial monitor 104 | SPI.begin(); // Start SPI bus 105 | rfidReader.PCD_Init(); // Start MFRC522 object 106 | 107 | while (!Serial); // Do nothing if no serial port is opened 108 | 109 | // Obviously this is an over simplified sketch 110 | // Master tags would be save in flash storage and 111 | // retrieved here. OR a special PIN entered to set 112 | // Master Tag. 113 | // But for the sake of simplicity, the sketch will 114 | // obtain a new master tag when restarted. 115 | 116 | // Prints the initial message 117 | Serial.println(F("-No Master Tag!-")); 118 | Serial.println(F(" SCAN NOW")); 119 | 120 | // readRFID will wait until a master card is scanned 121 | if (readRFID() == true) { 122 | myTags[tagsCount] = strdup(tagID.c_str()); // Sets the master tag into position 0 in the array 123 | Serial.println(F("Master Tag is Set!")); 124 | tagsCount++; 125 | } 126 | printNormalModeMessage(); 127 | } 128 | 129 | /* *********************************************************** 130 | * Void Loop * 131 | * ********************************************************* */ 132 | void loop() { 133 | if (isTagPresent()==true){ 134 | getTagID(); 135 | checkTagID(); 136 | } else { 137 | delay(50); 138 | //return; 139 | } 140 | 141 | } 142 | 143 | /* *********************************************************** 144 | * Functions * 145 | * ********************************************************* */ 146 | bool isTagPresent(){ 147 | /* isTagPresent uses the MFRC522 methods to determine if 148 | * a tag is present or the read card serial is enabled. 149 | * Parameters: (none) 150 | * Returns: 151 | * true - if tag detected or read card serial is true 152 | * false - no tag detected or no read card serial true 153 | */ 154 | bool returnValue = true; 155 | 156 | // NOT a new PICC_IsNewCardPresent in RFID reader 157 | //OR 158 | // NOT a PICC_ReadCardSerial active in Serial 159 | if ( !rfidReader.PICC_IsNewCardPresent() || !rfidReader.PICC_ReadCardSerial() ) { 160 | returnValue = false; 161 | } 162 | return returnValue; 163 | } 164 | 165 | byte checkMyTags(String tagID){ 166 | /* checkMyTags function loops through the array of myTags 167 | * Parameters: 168 | * tagID - a string to look for 169 | * Returns: 170 | * tagIndex - index in the array of myTags 171 | * default 0 172 | */ 173 | byte tagIndex = 0; 174 | //Serial.println("checkMyTags Started"); 175 | // Zero is reserved for master tag 176 | for (int i = 1; i < 100; i++) { 177 | if (tagID == myTags[i]) { tagIndex = i; } 178 | } 179 | //Serial.println("checkMyTags ended"); 180 | return tagIndex; 181 | } 182 | 183 | void checkTagID(){ 184 | /* checkTagID check the tag ID for authorized tag ID values 185 | * if Master tag found switch to program mode 186 | * Parameters: (none) 187 | * Returns: (none) 188 | */ 189 | // Checks for Master tag 190 | if (tagID == myTags[0]) { 191 | // Switch to program mode 192 | Serial.println(F(" Program mode:")); 193 | Serial.println(F(" Add/Remove Tag")); 194 | 195 | // Now with timeout 196 | // readRFID will skip if timeout exceeded 197 | if (readRFID(timeout,true)==true) { 198 | //Check for authorized tag 199 | byte tagIndex = checkMyTags(tagID); 200 | if (tagIndex!=0){ 201 | //Remove existing tag 202 | myTags[tagIndex] = '\0'; 203 | Serial.println(F(" Tag Removed!")); 204 | } else { 205 | //Not existing, add tag 206 | myTags[tagsCount] = strdup(tagID.c_str()); 207 | Serial.println(F(" Tag Added!")); 208 | tagsCount++; 209 | } 210 | } else { 211 | Serial.println(F(" timeout")); 212 | } 213 | } else { 214 | //Check for authorized tag 215 | byte tagIndex = checkMyTags(tagID); 216 | if (tagIndex!=0){ 217 | //Authorized tag 218 | Serial.println(F(" Access Granted!")); 219 | } else { 220 | //Not authorized tag 221 | Serial.println(F(" Access Denied!")); 222 | Serial.println(F(" New UID & Contents:")); 223 | rfidReader.PICC_DumpToSerial(&(rfidReader.uid)); 224 | } 225 | } 226 | printNormalModeMessage(); 227 | } 228 | 229 | bool getTagID() { 230 | /* getTagID retrieves the tag ID. Modifies global variable tagID 231 | * 232 | * Parameters: (none) 233 | * Returns: true 234 | */ 235 | 236 | tagID = ""; 237 | 238 | Serial.print(F(" UID tag: ")); 239 | for (byte i = 0; i < rfidReader.uid.size; i++){ 240 | // The MIFARE PICCs that we use have 4 byte UID 241 | Serial.print(rfidReader.uid.uidByte[i] < 0x10 ? " 0" : " "); 242 | Serial.print(rfidReader.uid.uidByte[i], HEX); 243 | // Adds the bytes in a single String variable 244 | tagID.concat(String(rfidReader.uid.uidByte[i] < 0x10 ? " 0" : " ")); 245 | tagID.concat(String(rfidReader.uid.uidByte[i], HEX)); 246 | } 247 | Serial.println(); 248 | Serial.println(); 249 | tagID.toUpperCase(); 250 | rfidReader.PICC_HaltA(); // Stop reading 251 | return true; 252 | } 253 | 254 | void printNormalModeMessage() { 255 | /* printNormalModeMessage sends the standard greeting 256 | * to the serial monitor. 257 | * Parameters: (none) 258 | * Returns: (none) 259 | */ 260 | delay(1500); 261 | Serial.println(); 262 | Serial.println(F("-Access Control-")); 263 | Serial.println(F(" Scan Your Tag!")); 264 | } 265 | -------------------------------------------------------------------------------- /Lesson 22 - LCD Display/HelloWorld/HelloWorld.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LiquidCrystal Library - Hello World 3 | 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal 5 | library works with all LCD displays that are compatible with the 6 | Hitachi HD44780 driver. There are many of them out there, and you 7 | can usually tell them by the 16-pin interface. 8 | 9 | This sketch prints "Hello World!" to the LCD 10 | and shows the time. 11 | 12 | The circuit: 13 | * LCD RS pin to digital pin 12 14 | * LCD Enable pin to digital pin 11 15 | * LCD D4 pin to digital pin 5 16 | * LCD D5 pin to digital pin 4 17 | * LCD D6 pin to digital pin 3 18 | * LCD D7 pin to digital pin 2 19 | * LCD R/W pin to ground 20 | * LCD VSS pin to ground 21 | * LCD VCC pin to 5V 22 | * 10K resistor: 23 | * ends to +5V and ground 24 | * wiper to LCD VO pin (pin 3) 25 | 26 | Library originally added 18 Apr 2008 27 | by David A. Mellis 28 | library modified 5 Jul 2009 29 | by Limor Fried (http://www.ladyada.net) 30 | example added 9 Jul 2009 31 | by Tom Igoe 32 | modified 22 Nov 2010 33 | by Tom Igoe 34 | modified 7 Nov 2016 35 | by Arturo Guadalupi 36 | 37 | This example code is in the public domain. 38 | 39 | http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld 40 | 41 | */ 42 | 43 | // include the library code: 44 | #include 45 | // I2C library: 46 | //#include 47 | 48 | // initialize the library by associating any needed LCD interface pin 49 | // with the arduino pin number it is connected to 50 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 51 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 52 | // I2C: use the line below 53 | // Parameters: LCD address, number of columns = 16, and the number of rows = 2 54 | //LiquidCrystal lcd(0x3F, 16, 2); 55 | 56 | void setup() { 57 | // Normal begin statement for LCD requiring the number of columns and rows: 58 | lcd.begin(16, 2); // Direct wire statement 59 | // I2C begin statement: 60 | //lcd.begin(); // I2C statement 61 | 62 | // I2C: Turn on the blacklight 63 | //lcd.backlight(); 64 | 65 | // Print a message to the LCD. 66 | lcd.print("hello, world!"); 67 | } 68 | 69 | void loop() { 70 | // set the cursor to column 0, line 1 71 | // (note: line 1 is the second row, since counting begins with 0): 72 | lcd.setCursor(0, 1); 73 | // print the number of seconds since reset: 74 | lcd.print(millis() / 1000); 75 | } 76 | -------------------------------------------------------------------------------- /Lesson 22 - LCD Display/I2C_check/I2C_check.ino: -------------------------------------------------------------------------------- 1 | // sample code we found on google.com 2 | // discovers connected I2C devices 3 | // and displayes their address locations 4 | 5 | #include 6 | 7 | 8 | void setup() 9 | { 10 | Wire.begin(); 11 | 12 | Serial.begin(9600); 13 | while (!Serial); 14 | Serial.println("\nI2C Scanner"); 15 | } 16 | 17 | 18 | void loop() 19 | { 20 | byte error, address; 21 | int nDevices; 22 | 23 | Serial.println("Scanning..."); 24 | 25 | nDevices = 0; 26 | for(address = 1; address < 127; address++ ) 27 | { 28 | // The i2c_scanner uses the return value of 29 | // the Write.endTransmisstion to see if 30 | // a device did acknowledge to the address. 31 | Wire.beginTransmission(address); 32 | error = Wire.endTransmission(); 33 | 34 | if (error == 0) 35 | { 36 | Serial.print("I2C device found at address 0x"); 37 | if (address<16) 38 | Serial.print("0"); 39 | Serial.print(address,HEX); 40 | Serial.println(" !"); 41 | 42 | nDevices++; 43 | } 44 | else if (error==4) 45 | { 46 | Serial.print("Unknow error at address 0x"); 47 | if (address<16) 48 | Serial.print("0"); 49 | Serial.println(address,HEX); 50 | } 51 | } 52 | if (nDevices == 0) 53 | Serial.println("No I2C devices found\n"); 54 | else 55 | Serial.println("done\n"); 56 | 57 | delay(5000); // wait 5 seconds for next scan 58 | } 59 | -------------------------------------------------------------------------------- /Lesson 22 - LCD Display/LCD1602A.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 22 - LCD Display/LCD1602A.fzz -------------------------------------------------------------------------------- /Lesson 22 - LCD Display/LCD1602A_I2C.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 22 - LCD Display/LCD1602A_I2C.fzz -------------------------------------------------------------------------------- /Lesson 22 - LCD Display/LCD1602A_I2C_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 22 - LCD Display/LCD1602A_I2C_bb.png -------------------------------------------------------------------------------- /Lesson 22 - LCD Display/LCD1602A_I2C_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 22 - LCD Display/LCD1602A_I2C_schem.png -------------------------------------------------------------------------------- /Lesson 22 - LCD Display/LCD1602A_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 22 - LCD Display/LCD1602A_bb.png -------------------------------------------------------------------------------- /Lesson 22 - LCD Display/LCD1602A_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 22 - LCD Display/LCD1602A_schem.png -------------------------------------------------------------------------------- /Lesson 22 - LCD Display/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 22 - LCD Display/README.md -------------------------------------------------------------------------------- /Lesson 22 - LCD Display/fdebrabander-LiquidCrystal-I2C.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 22 - LCD Display/fdebrabander-LiquidCrystal-I2C.zip -------------------------------------------------------------------------------- /Lesson 23 - Thermometer/README.md: -------------------------------------------------------------------------------- 1 | # ElegooTutorial 2 | 3 | ## Lesson 23 – Thermometer 4 | 5 | 6 | [![YouTube video](https://img.youtube.com/vi/4x23DP97qMM/0.jpg)](https://youtu.be/4x23DP97qMM) 7 | [YouTube video](https://youtu.be/4x23DP97qMM) 8 | 9 | Thermistor MF52 A 103 F 3950. Demonstrate an inspired Elegoo sketch provided in the tutorial covering the Thermistor, using it as a thermometer. A beginner's guide to the Most Complete Starter Kit by Elegoo. 10 | 11 | Hello everyone, I'm Rick the Tech Enthusiast here with the next Elegoo Lesson. This is the next lesson on my Arduino UNO Series covering the Most Complete Starter Kit by Elegoo. I try to follow the included tutorial and will point out any changes or corrections as I find them. 12 | 13 | As mentioned before, I purchased this Elegoo starter kit and Elegoo isn't sponsoring me. I just thought it would be fun to do a video of each Lesson as I was learning the Arduino environment. 14 | 15 | We’ll need a few things from your Elegoo Arduino UNO kit. I’ll list the items below. In this lesson we’re going to check out an NTC Thermistor, a resistive device that changes with temperature. I’ll step through an Elegoo inspired tutorial, briefly explain the code, and build and configure a simple circuit that is to demonstrate the functionality. I hope you enjoy it. 16 | 17 | ## Parts you’ll need for the tutorial 18 | 19 | * Elegoo Uno R3 board 20 | * 1602A LCD module 21 | * Thermistor 22 | * 10K Potentiometer 23 | * 10K-ohm resistor 24 | * 220-ohm resistor 25 | * A bunch of jumper wires. 26 | 27 | The next lesson will be Lesson 24: Eight LED with 74HC595 28 | 29 | ## Links 30 | 31 | This lesson’s sketch and associated drawings can be found at [Github](https://github.com/rmorenojr/ElegooTutorial) 32 | 33 | Various Parts can be found: 34 | * [MAX7219 LED Dot Matrix Module 8 x 8 with 5pcs Dupont Line – Amazon](https://www.amazon.com/gp/product/B07775NFS1/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325) 35 | * [DHT21 AM2301 Capacitive Digital Temperature and Humidity Sensor](https://www.amazon.com/AM2301-Capacitive-Digital-Temperature-Humidity/dp/B07543HBQ2) – amazon 36 | * [SODIAL(R) DHT22 AM2302 Digital Temperature and Humidity Sensor Module](https://www.amazon.com/SODIAL-Digital-Temperature-Humidity-Raspberry/dp/B0757FBWSB/ref=sr_1_19?s=industrial&ie=UTF8&qid=1520801854&sr=1-19&keywords=dht22) 37 | * [DHT22 AM2302 Digital Temperature and Humidity Sensor Module](https://www.amazon.com/Digital-Temperature-Humidity-Arduino-Raspberry/dp/B01N6PB489/ref=sr_1_4?s=industrial&ie=UTF8&qid=1520801995&sr=1-4&keywords=dht22) - amazon 38 | * [SunFounder LCD1602 Module with 3.3V Backlight for Arduino Uno R3 Mega2560 Raspberry Pi 16x2 Character White on Blue Background](https://www.amazon.com/gp/product/B071Y6JX3H/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B071Y6JX3H&linkCode=as2&tag=rmorenojr-20&linkId=81e6c312179be2b149bf6eeae0051f14) 39 | 40 | * [Cylewet 10Pcs 5V 2 Terminals Passive Electronic Alarm Buzzer Electromagnetic Beeper AC Impedance for Arduino (Pack of 10) CYT1008](https://www.amazon.com/gp/product/B01NCOXB2Q/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B01NCOXB2Q&linkCode=as2&tag=rmorenojr-20&linkId=65e4660761a54140f64e954f1770006e) 41 | * [Elenco 350 Piece Pre-formed Jumper Wire Kit on Amazon](https://amzn.to/2z6sCCw) 42 | * [Elegoo EL-KIT-001 UNO R3 Project Complete Starter Kit with Tutorial for Arduino (63 Items)](https://www.amazon.com/gp/product/B01CZTLHGE/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B01CZTLHGE&linkCode=as2&tag=rmorenojr-20&linkId=ac3601531bad9439bc32c77b0088b741) 43 | * [Elegoo’s web site](https://www.elegoo.com/) - [Complete Starter Kit](https://www.elegoo.com/product/elegoo-uno-r3-project-complete-starter-kit/) 44 | * [Logitech M510 Wireless Mouse on Amazon](https://amzn.to/2z4FF7F) 45 | 46 | Software & Links: 47 | * [Fritzing Software](http://fritzing.org/download/) 48 | * [Arduino Language Reference (English)](https://www.arduino.cc/reference/en/) 49 | * [Steinhart–Hart equation](https://en.wikipedia.org/wiki/Steinhart–Hart_equation) 50 | * [Measuring Temperature with an NTC Thermistor](https://www.allaboutcircuits.com/projects/measuring-temperature-with-an-ntc-thermistor/) 51 | * [NTC Thermistor Calculating the Temperature Coefficient of a Thermistor](https://www.ametherm.com/thermistor/ntc-thermistor-calculating-the-temperature-coefficient-of-a-thermistor) 52 | * [NTC Thermistor Beta](https://www.ametherm.com/thermistor/ntc-thermistor-beta) 53 | * [Connecting to a Thermistor](https://learn.adafruit.com/thermistor/using-a-thermistor) 54 | * [Tutorial 23: Smoothing Data](https://programmingelectronics.com/tutorial-23-smoothing-data-old-version/) 55 | 56 | 57 | 58 | ## Affiliate Links that Help my channel: 59 | * Try Prime Discounted Monthly Offering: https://amzn.to/2PnVgSA 60 | * Try Amazon Prime 30-Day Free Trial: https://amzn.to/2E5Hy4O 61 | * Prime Student 6-month Trial: https://amzn.to/2ElxwNE 62 | * Join Amazon Prime - Watch Thousands of Movies & TV Shows Anytime - Start Free Trial Now: https://amzn.to/2PsEZvE 63 | * Give the Gift of Amazon Prime https://amzn.to/2EkFaYG 64 | * Kindle Unlimited Membership Plans: https://amzn.to/2QJl548 65 | * Try Audible and Get Two Free Audiobooks: https://amzn.to/2QD2B5v 66 | * Amazon.com - Read eBooks using the FREE Kindle Reading App on Most Devices: https://amzn.to/2Ptpdkl 67 | 68 | * Royalty Free Music from HookSounds.com, by artist Rodrigo Vicente - [FutureBass_Full](http://www.hooksounds.com) 69 | 70 | This is another video for my new Arduino tutorial series. If you like the series, be sure to rate and subscribe. 71 | 72 | Thanks for watching 73 | -------------------------------------------------------------------------------- /Lesson 23 - Thermometer/Thermistor Calculator.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 23 - Thermometer/Thermistor Calculator.xlsx -------------------------------------------------------------------------------- /Lesson 23 - Thermometer/Thermistor.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 23 - Thermometer/Thermistor.fzz -------------------------------------------------------------------------------- /Lesson 23 - Thermometer/Thermistor_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 23 - Thermometer/Thermistor_bb.png -------------------------------------------------------------------------------- /Lesson 23 - Thermometer/Thermistor_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 23 - Thermometer/Thermistor_schem.png -------------------------------------------------------------------------------- /Lesson 23 - Thermometer/Thermometer/Thermometer.ino: -------------------------------------------------------------------------------- 1 | /* *********************************************************** 2 | * Thermometer 3 | * uses the LiquidCrystal.h Library 4 | * uses LiquidCrystal_I2C.h 5 | * 6 | * Inspired by Elegoo Lesson 23 and 7 | * Measuring Temperature with an NTC Thermistor by all about circuits 8 | * https://www.allaboutcircuits.com/projects/measuring-temperature-with-an-ntc-thermistor/ 9 | * 10 | * The circuit: 11 | * 5v ----\/\/\/-------|-------\/\/\/---- GND 12 | * R_thermistor | R_2 13 | * | 14 | * Analog Pin A0 15 | * 16 | * Ardino 17 | * UNO: 10K POT 220-ohms 18 | * 5V --\/\/\/--- GND 5V --\/\/\/-| 19 | * | wiper | 20 | * | | 21 | * Uno: GND 5V | 12 11 5 4 3 2 | GND 22 | * -|---|---|---|---|---|---|---|---|---|---|---|---|---|---| 23 | * LCD: VSS VDD V0 RS E D0 D1 D2 D3 D4 D5 D6 D7 A K 24 | * 25 | * Description: 26 | * This sketch illustrates the Thermistor using a smoothing techique 27 | * and the LCD. 28 | * 29 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 30 | * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 31 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 32 | * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 33 | * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 34 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 35 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 36 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 37 | * 38 | * History: 39 | * 02/24/2019 v1.0 - Initial release 40 | * 41 | * ********************************************************* */ 42 | 43 | /* *********************************************************** 44 | * Libraries * 45 | * ********************************************************* */ 46 | #include // Standard LCD library 47 | //#include // I2C LCD Library 48 | 49 | /* *********************************************************** 50 | * Global Constants * 51 | * Hardware Definitions * 52 | * ********************************************************* */ 53 | // Standard LCD pin connection 54 | const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 55 | LiquidCrystal lcd(rs, en, d4, d5, d6, d7); // instantiate lcd 56 | // I2C LCD connection 57 | //LiquidCrystal lcd(0x3F, 16, 2); // LCD address, #columns, #rows 58 | 59 | const int thermistorPin = A0; // Thermistor pin 60 | const float Resistor2 = 10000.0; // R2 resistor Value 61 | const int SampleNumber = 30; // The number of analog samples (30 max for integer) 62 | const int aMax = 1023; // Maximum Analog value 1023 63 | const float t25 = 25.0+273.15; // Temperature in Kelvin at 25C 64 | const float r25 = 10000.0; // Thermistor resistance at 25C 65 | const float Beta = 3950.0; // Thermistor Beta from the datasheet 66 | //Steinhart-Hart Coefficient values - calculated 67 | const float scA = 0.00102219653793705; 68 | const float scB = 0.000253179116444952; 69 | const float scC = -0.000000000058799201163101; 70 | 71 | /* *********************************************************** 72 | * Global Variables * 73 | * ********************************************************* */ 74 | int aValues[SampleNumber]; // Analog value Array 75 | int index = 0; // Tracks the array index 76 | int total = 0; // Keeps a running total 77 | 78 | /* *********************************************************** 79 | * Void Setup * 80 | * ********************************************************* */ 81 | void setup() { 82 | /* ********************************** 83 | * Normal begin statement for LCD * 84 | * (#columns, #rows) * 85 | ********************************** */ 86 | lcd.begin(16, 2); // Direct wire statement 87 | /* ********************************** 88 | * I2C begin statements * 89 | ********************************** */ 90 | //lcd.begin(); // I2C statement 91 | //lcd.backlight(); // Turn on the blacklight 92 | 93 | // Reset or initialize array 94 | int aValue = analogRead(thermistorPin); // Get inital analog value seed 95 | for(int x=0; x= SampleNumber){index = 0;} // Reset index if >= SampleNumber 119 | float Average = float(total) / float(SampleNumber); // Calculate average 120 | float rThermistor = Resistor2 * (float(aMax)/Average - 1.0); // Thermistor resistance 121 | float tKelvin = 1.0/(scA + scB * log(rThermistor) + scC * (pow(log(rThermistor),3))); 122 | float tCelsius = tKelvin - 273.15; // Convert Kelvin to Celsius 123 | return(tCelsius); 124 | 125 | //tKelvin = 1 / (0.001129148 + 0.000234125 * log(rThermistor) + 0.0000000876741 * pow(log(rThermistor),3))); 126 | // where A = 0.001129148, B = 0.000234125, and C = 0.0000000876741 127 | // how were these calculated? 128 | } 129 | 130 | void displayTemperature(float tCelsius){ 131 | float tFahrenheit = (tCelsius * 9.0)/ 5.0 + 32.0; // Calculate Fahrenheit 132 | 133 | // Display Temperature in C 134 | lcd.setCursor(0, 0); // First row 135 | lcd.print("Temp C "); // Updates and clear display row 136 | lcd.setCursor(12, 0); // Locate degree symbol 137 | lcd.print((char)223); // prints the degree symbol 138 | lcd.setCursor(6, 0); // Locate temperature 139 | lcd.print(tCelsius); 140 | // Display Temperature in F 141 | lcd.setCursor(0, 1); // Second Row 142 | lcd.print(" F "); // Updates and clear display row 143 | lcd.setCursor(12, 1); // Locate degree symbol 144 | lcd.print((char)223); // prints the degree symbol 145 | lcd.setCursor(6, 1); // Locate temperature 146 | lcd.print(tFahrenheit); 147 | } 148 | -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/74HC595-shift-register-pinout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 24 - 74HC595 Shift Register/74HC595-shift-register-pinout.png -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/74HC595.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 24 - 74HC595 Shift Register/74HC595.fzz -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/74HC595_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 24 - 74HC595 Shift Register/74HC595_bb.png -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/74HC595_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 24 - 74HC595 Shift Register/74HC595_schem.png -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/B2B_74HC595.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 24 - 74HC595 Shift Register/B2B_74HC595.fzz -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/B2B_74HC595_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 24 - 74HC595 Shift Register/B2B_74HC595_bb.png -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/B2B_74HC595_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 24 - 74HC595 Shift Register/B2B_74HC595_schem.png -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/README.md: -------------------------------------------------------------------------------- 1 | # ElegooTutorial 2 | 3 | ## Lesson 24 – Eight LED with 74HC595, or 74HC595 shift register 4 | 5 | 6 | [![YouTube video](https://img.youtube.com/vi/ou3WP3Hp5X0/0.jpg)](https://youtu.be/ou3WP3Hp5X0) 7 | [YouTube video](https://youtu.be/ou3WP3Hp5X0) 8 | 9 | Eight LED with 74HC595, or 74HC595 shift register. Demonstrate the tutorial’s sketch and expand the sketch to show back to back shift registers. A beginner's guide to the Most Complete Starter Kit by Elegoo. 10 | 11 | Hello everyone, I'm Rick the Tech Enthusiast here with the next Elegoo Lesson. This is the next lesson on my Arduino UNO Series covering the Most Complete Starter Kit by Elegoo. I try to follow the included tutorial and will point out any changes or corrections as I find them. 12 | 13 | As mentioned before, I purchased this Elegoo starter kit and Elegoo isn't sponsoring me. I just thought it would be fun to do a video of each Lesson as I was learning the Arduino environment. 14 | 15 | We’ll need a few things from your Elegoo Arduino UNO kit. I’ll list the items below. In this lesson we’re going to check out the 74HC595 shift register, a digital output port expanding device that uses only three Arduino outputs. I’ll step through the Elegoo tutorial, briefly explain the code, and build and configure a simple circuit that is to demonstrate the functionality. Then I’ll expand the circuit with back to back shift registers to control 16 outputs. I hope you enjoy it. 16 | 17 | ## Parts you’ll need for the tutorial 18 | 19 | * Elegoo Uno R3 board 20 | * 74HC595 shift register IC 21 | * 8 LEDS, 2 blue, 2 yellow, 2 red, and 2 green 22 | * 8 220-ohm resistors 23 | * The breadboard 24 | * A bunch of male-to-male jumper wires (about 13 or so). 25 | The expanded circuit requires an additional 74HC595 shift register and additional 220-ohm resisters purchased separately. 26 | 27 | The next lesson will be Lesson 25: The Serial Monitor 28 | 29 | ## Links 30 | 31 | This lesson’s sketch and associated drawings can be found at [Github](https://github.com/rmorenojr/ElegooTutorial) 32 | 33 | Various Parts can be found: 34 | * [74HC595 8-Bit Shift Register with Output Latching, DIP 16, Cascadable (Pack of 10)](https://amzn.to/2O9RFbO) 35 | * [MAX7219 LED Dot Matrix Module 8 x 8 with 5pcs Dupont Line – Amazon](https://www.amazon.com/gp/product/B07775NFS1/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325) 36 | * [DHT21 AM2301 Capacitive Digital Temperature and Humidity Sensor](https://www.amazon.com/AM2301-Capacitive-Digital-Temperature-Humidity/dp/B07543HBQ2) – amazon 37 | * [SODIAL(R) DHT22 AM2302 Digital Temperature and Humidity Sensor Module](https://www.amazon.com/SODIAL-Digital-Temperature-Humidity-Raspberry/dp/B0757FBWSB/ref=sr_1_19?s=industrial&ie=UTF8&qid=1520801854&sr=1-19&keywords=dht22) 38 | * [DHT22 AM2302 Digital Temperature and Humidity Sensor Module](https://www.amazon.com/Digital-Temperature-Humidity-Arduino-Raspberry/dp/B01N6PB489/ref=sr_1_4?s=industrial&ie=UTF8&qid=1520801995&sr=1-4&keywords=dht22) - amazon 39 | 40 | * SunFounder LCD1602 Module with 3.3V Backlight for Arduino Uno R3 Mega2560 Raspberry Pi 16x2 Character White on Blue Background 41 | 42 | * [Cylewet 10Pcs 5V 2 Terminals Passive Electronic Alarm Buzzer Electromagnetic Beeper AC Impedance for Arduino (Pack of 10) CYT1008](https://www.amazon.com/gp/product/B01NCOXB2Q/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B01NCOXB2Q&linkCode=as2&tag=rmorenojr-20&linkId=65e4660761a54140f64e954f1770006e) 43 | * [Elenco 350 Piece Pre-formed Jumper Wire Kit on Amazon](https://amzn.to/2z6sCCw) 44 | * [Elegoo EL-KIT-001 UNO R3 Project Complete Starter Kit with Tutorial for Arduino (63 Items)](https://www.amazon.com/gp/product/B01CZTLHGE/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B01CZTLHGE&linkCode=as2&tag=rmorenojr-20&linkId=ac3601531bad9439bc32c77b0088b741) 45 | * [Elegoo’s web site](https://www.elegoo.com/) - [Complete Starter Kit](https://www.elegoo.com/product/elegoo-uno-r3-project-complete-starter-kit/) 46 | * [Logitech M510 Wireless Mouse on Amazon](https://amzn.to/2z4FF7F) 47 | 48 | Software & Links: 49 | * [Fritzing Software](http://fritzing.org/download/) 50 | * [Arduino Language Reference (English)](https://www.arduino.cc/reference/en/) 51 | * [Arduino bitset](https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitset/) 52 | * [Arduino shiftout](https://www.arduino.cc/reference/en/language/functions/advanced-io/shiftout/) 53 | 54 | ## Affiliate Links that Help my channel: 55 | * Try Prime Discounted Monthly Offering: https://amzn.to/2PnVgSA 56 | * Try Amazon Prime 30-Day Free Trial: https://amzn.to/2E5Hy4O 57 | * Prime Student 6-month Trial: https://amzn.to/2ElxwNE 58 | * Join Amazon Prime - Watch Thousands of Movies & TV Shows Anytime - Start Free Trial Now: https://amzn.to/2PsEZvE 59 | * Give the Gift of Amazon Prime https://amzn.to/2EkFaYG 60 | * Kindle Unlimited Membership Plans: https://amzn.to/2QJl548 61 | * Try Audible and Get Two Free Audiobooks: https://amzn.to/2QD2B5v 62 | * Amazon.com - Read eBooks using the FREE Kindle Reading App on Most Devices: https://amzn.to/2Ptpdkl 63 | 64 | * Royalty Free Music from HookSounds.com, by artist Rodrigo Vicente - [FutureBass_Full](http://www.hooksounds.com) 65 | 66 | This is another video for my new Arduino tutorial series. If you like the series, be sure to rate and subscribe. 67 | 68 | Thanks for watching 69 | -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/SR_74HC595/SR_74HC595.ino: -------------------------------------------------------------------------------- 1 | /* ********************************************************************** 2 | * Shift Register 74HC595 with LEDs 3 | * 4 | * Inspired by Elegoo Lesson 24 5 | * www.elegoo.com 2016.12.9 6 | * 7 | * Circuit: 8 | * 9 | * LED D12 D11 10 | * 5V 0 MISO GND MOSI D9 5V 11 | * | | | | | | | | 12 | * |--|----|----|----|----|----|----|----|--| 13 | * | VCC Q0 DS OE ST_CP SH_CP MR Q7' | 14 | * | | 15 | * | Q1 Q2 Q3 Q4 Q5 Q6 Q7 GND | 16 | * |--|----|----|----|----|----|----|----|--| 17 | * | | | | | | | | 18 | * LED LED LED LED LED LED LED GND 19 | * 1 2 3 4 5 6 7 20 | * 21 | * https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitset/ 22 | * https://www.arduino.cc/reference/en/language/functions/advanced-io/shiftout/ 23 | ********************************************************************* */ 24 | 25 | /* *************************************************** 26 | * Globsl Constants * 27 | *************************************************** */ 28 | int tDelay = 100; 29 | int dataPin = 12; // DS - data serial on 74HC595 30 | int latchPin = 11; // ST_CP - storage register clock pin on 74HC595 31 | int clockPin = 9; // SH_CP - shift register clock pin on 74HC595 - Why not D13 SCK pin? 32 | 33 | /* *************************************************** 34 | * Globsl Variables * 35 | *************************************************** */ 36 | bool DirectionState = 0; 37 | 38 | /* *************************************************** 39 | * Functions * 40 | *************************************************** */ 41 | void updateShiftRegister(byte leds){ 42 | digitalWrite(latchPin, LOW); 43 | if (DirectionState == false) { 44 | shiftOut(dataPin, clockPin, LSBFIRST, leds); 45 | } else { 46 | shiftOut(dataPin, clockPin, MSBFIRST, leds); 47 | } 48 | digitalWrite(latchPin, HIGH); 49 | } 50 | 51 | /* *************************************************** 52 | * Void Setup * 53 | *************************************************** */ 54 | void setup(){ 55 | pinMode(latchPin, OUTPUT); 56 | pinMode(dataPin, OUTPUT); 57 | pinMode(clockPin, OUTPUT); 58 | } 59 | 60 | /* *************************************************** 61 | * Void Loop * 62 | *************************************************** */ 63 | void loop(){ 64 | byte leds = 0B00000000; 65 | updateShiftRegister(leds); 66 | delay(tDelay); 67 | 68 | for (int i = 0; i < 8; i++){ 69 | // set the bit i to 1, starting with bit 0, the least significant bit (rightmost bit) 70 | bitSet(leds, i); 71 | updateShiftRegister(leds); 72 | delay(tDelay); 73 | } 74 | DirectionState = !DirectionState; 75 | } 76 | 77 | -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/SR_74HC595_16bit/SR_74HC595_16bit.ino: -------------------------------------------------------------------------------- 1 | /* ********************************************************************** 2 | * Shift Register 74HC595 with 16 LEDs 3 | * back to back shift registers 4 | * 5 | * Inspired by Elegoo Lesson 24 6 | * www.elegoo.com 2016.12.9 7 | * 8 | * Circuit: 9 | * ____________________ 10 | * LED D12 D11 | LED | D11 11 | * 5V 0 MISO GND MOSI D9 5V | 5V 8 | GND MOSI D9 5V 12 | * | | | | | | | | | | | | | | | | 13 | * |--|----|----|----|----|----|----|----|--| |--|----|----|----|----|----|----|----|--| 14 | * | VCC Q0 DS OE ST_CP SH_CP MR Q7' | | VCC Q0 DS OE ST_CP SH_CP MR Q7' | 15 | * | | | | 16 | * | Q1 Q2 Q3 Q4 Q5 Q6 Q7 GND | | Q1 Q2 Q3 Q4 Q5 Q6 Q7 GND | 17 | * |--|----|----|----|----|----|----|----|--| |--|----|----|----|----|----|----|----|--| 18 | * | | | | | | | | | | | | | | | | 19 | * LED LED LED LED LED LED LED GND LED LED LED LED LED LED LED GND 20 | * 1 2 3 4 5 6 7 9 10 11 12 13 14 15 21 | * 22 | * https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitset/ 23 | * https://www.arduino.cc/reference/en/language/functions/advanced-io/shiftout/ 24 | ********************************************************************* */ 25 | 26 | /* *************************************************** 27 | * Global Constants * 28 | *************************************************** */ 29 | const int tDelay = 100; // delay between LED switching 30 | const int dataPin = 12; // DS - data serial 31 | const int latchPin = 11; // ST_CP - storage register, latch clock pin 32 | const int clockPin = 9; // SH_CP - shift register clock pin 33 | 34 | /* *************************************************** 35 | * Global Variables * 36 | *************************************************** */ 37 | bool DirectionState = 0; 38 | 39 | /* *************************************************** 40 | * Functions * 41 | *************************************************** */ 42 | void updateShiftRegister(unsigned int leds, bool isMSBFIRST = true){ 43 | /* Performs all the necessary work to serial load 44 | * two shift registers. Direction controlled by 45 | * isMSBFIRST 46 | * Paramters: 47 | * leds - insigned 16-bit number {required} 48 | * isMSBFISRT - boolean for direction 49 | * true = MSBFIRST 50 | * false = LSBFIRST 51 | * called by void loop */ 52 | 53 | /* Local variables */ 54 | /* example: Higher byte Lower byte 55 | * 16-bit word = 00000000 00000000 */ 56 | byte lowLED = lowByte(leds); // extacts the lower byte, right most byte, from a 16-bit word or unsigned integer 57 | byte highLED = highByte(leds); // extracts the higher byte, left most byte, from a 16-bit word or unsigned integer 58 | 59 | digitalWrite(latchPin, LOW); 60 | if (isMSBFIRST == false) { 61 | // LEDs move from right to left 62 | shiftOut(dataPin, clockPin, LSBFIRST, lowLED); // shiftout only works with a byte value 63 | shiftOut(dataPin, clockPin, LSBFIRST, highLED); 64 | } else { 65 | // LEDs move from left to right 66 | shiftOut(dataPin, clockPin, MSBFIRST, highLED); 67 | shiftOut(dataPin, clockPin, MSBFIRST, lowLED); 68 | } 69 | digitalWrite(latchPin, HIGH); 70 | } 71 | 72 | /* *************************************************** 73 | * Void Setup * 74 | *************************************************** */ 75 | void setup(){ 76 | pinMode(latchPin, OUTPUT); 77 | pinMode(dataPin, OUTPUT); 78 | pinMode(clockPin, OUTPUT); 79 | } 80 | 81 | /* *************************************************** 82 | * Void Loop * 83 | *************************************************** */ 84 | void loop(){ 85 | unsigned int leds = 0B0000000000000000; 86 | updateShiftRegister(leds); 87 | delay(tDelay); 88 | 89 | for (int i = 0; i < 16; i++){ 90 | // set the bit i to 1, starting with bit 0, the least significant bit (rightmost bit) 91 | leds = 0B0000000000000000; 92 | bitSet(leds, i); 93 | updateShiftRegister(leds, DirectionState); 94 | delay(tDelay); 95 | } 96 | DirectionState = !DirectionState; 97 | } 98 | -------------------------------------------------------------------------------- /Lesson 24 - 74HC595 Shift Register/SR_74HC595_32bit/SR_74HC595_32bit.ino: -------------------------------------------------------------------------------- 1 | /* ********************************************************************** 2 | * Shift Register 74HC595 with 32 LEDs 3 | * Four back to back shift registers 4 | * 5 | * Inspired by Elegoo Lesson 24 6 | * www.elegoo.com 2016.12.9 7 | * 8 | * Circuit: 9 | * ____________________ ____________________ ____________________ 10 | * LED D12 D11 | LED | D11 | LED | D11 | LED | D11 11 | * 5V 0 MISO GND MOSI D9 5V | 5V 8 | GND MOSI D9 5V | 5V 16 | GND MOSI D9 5V | 5V 24 | GND MOSI D9 5V 12 | * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 13 | * |--|----|----|----|----|----|----|----|--| |--|----|----|----|----|----|----|----|--| |--|----|----|----|----|----|----|----|--| |--|----|----|----|----|----|----|----|--| 14 | * | VCC Q0 DS OE ST_CP SH_CP MR Q7' | | VCC Q0 DS OE ST_CP SH_CP MR Q7' | | VCC Q0 DS OE ST_CP SH_CP MR Q7' | | VCC Q0 DS OE ST_CP SH_CP MR Q7' | 15 | * | | | | | | | | 16 | * | Q1 Q2 Q3 Q4 Q5 Q6 Q7 GND | | Q1 Q2 Q3 Q4 Q5 Q6 Q7 GND | | Q1 Q2 Q3 Q4 Q5 Q6 Q7 GND | | Q1 Q2 Q3 Q4 Q5 Q6 Q7 GND | 17 | * |--|----|----|----|----|----|----|----|--| |--|----|----|----|----|----|----|----|--| |--|----|----|----|----|----|----|----|--| |--|----|----|----|----|----|----|----|--| 18 | * | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 19 | * LED LED LED LED LED LED LED GND LED LED LED LED LED LED LED GND LED LED LED LED LED LED LED GND LED LED LED LED LED LED LED GND 20 | * 1 2 3 4 5 6 7 9 10 11 12 13 14 15 17 18 19 20 21 22 23 25 26 27 28 29 30 31 21 | * 22 | * https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitset/ 23 | * https://www.arduino.cc/reference/en/language/functions/advanced-io/shiftout/ 24 | ********************************************************************* */ 25 | 26 | /* *************************************************** 27 | * Global Constants * 28 | *************************************************** */ 29 | const int tDelay = 100; // delay between LED switching 30 | const int dataPin = 12; // DS - data serial 31 | const int latchPin = 11; // ST_CP - storage register, latch clock pin 32 | const int clockPin = 9; // SH_CP - shift register clock pin 33 | 34 | /* *************************************************** 35 | * Global Variables * 36 | *************************************************** */ 37 | bool DirectionState = 0; 38 | 39 | /* *************************************************** 40 | * Functions * 41 | *************************************************** */ 42 | void updateShiftRegister(unsigned long leds, bool isMSBFIRST = true){ 43 | /* Performs all the necessary work to serial load 44 | * two shift registers. Direction controlled by 45 | * isMSBFIRST 46 | * Paramters: 47 | * leds - insigned 16-bit number {required} 48 | * isMSBFISRT - boolean for direction 49 | * true = MSBFIRST 50 | * false = LSBFIRST 51 | * called by void loop */ 52 | 53 | /* Local variables */ 54 | unsigned int leds16 = int(leds); 55 | unsigned int leds32 = int(leds>>16); 56 | /* example: Higher byte Lower byte 57 | * 16-bit word = 00000000 00000000 */ 58 | byte low16LED = lowByte(leds16); // extacts the lower byte, right most byte, from a 16-bit word or unsigned integer 59 | byte high16LED = highByte(leds16); // extracts the higher byte, left most byte, from a 16-bit word or unsigned integer 60 | byte low32LED = lowByte(leds32); 61 | byte high32LED = highByte(leds32); 62 | 63 | digitalWrite(latchPin, LOW); 64 | if (isMSBFIRST == false) { 65 | // LEDs move from right to left 66 | shiftOut(dataPin, clockPin, LSBFIRST, low16LED); // shiftout only works with a byte value 67 | shiftOut(dataPin, clockPin, LSBFIRST, high16LED); 68 | shiftOut(dataPin, clockPin, LSBFIRST, low32LED); // shiftout only works with a byte value 69 | shiftOut(dataPin, clockPin, LSBFIRST, high32LED); 70 | } else { 71 | // LEDs move from left to right 72 | shiftOut(dataPin, clockPin, MSBFIRST, high32LED); 73 | shiftOut(dataPin, clockPin, MSBFIRST, low32LED); 74 | shiftOut(dataPin, clockPin, MSBFIRST, high16LED); 75 | shiftOut(dataPin, clockPin, MSBFIRST, low16LED); 76 | } 77 | digitalWrite(latchPin, HIGH); 78 | } 79 | 80 | /* *************************************************** 81 | * Void Setup * 82 | *************************************************** */ 83 | void setup(){ 84 | pinMode(latchPin, OUTPUT); 85 | pinMode(dataPin, OUTPUT); 86 | pinMode(clockPin, OUTPUT); 87 | } 88 | 89 | /* *************************************************** 90 | * Void Loop * 91 | *************************************************** */ 92 | void loop(){ 93 | unsigned long leds = 0B11111111111111111111111111111111; 94 | updateShiftRegister(leds); 95 | delay(tDelay); 96 | leds = 0B00000000000000000000000000000000; 97 | updateShiftRegister(leds); 98 | delay(tDelay); 99 | leds = 0B11111111111111111111111111111111; 100 | updateShiftRegister(leds); 101 | delay(tDelay); 102 | 103 | for (int i = 0; i < 32; i++){ 104 | // set the bit i to 1, starting with bit 0, the least significant bit (rightmost bit) 105 | leds = 0B00000000000000000000000000000000; 106 | bitSet(leds, i); 107 | updateShiftRegister(leds, DirectionState); 108 | delay(tDelay); 109 | } 110 | DirectionState = !DirectionState; 111 | } 112 | -------------------------------------------------------------------------------- /Lesson 26 - Photocell/PhotoCell.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 26 - Photocell/PhotoCell.fzz -------------------------------------------------------------------------------- /Lesson 26 - Photocell/PhotoCell_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 26 - Photocell/PhotoCell_bb.png -------------------------------------------------------------------------------- /Lesson 26 - Photocell/PhotoCell_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 26 - Photocell/PhotoCell_schem.png -------------------------------------------------------------------------------- /Lesson 27 - 74HC595 and Segment Display/7-SegmentDisplay/7-SegmentDisplay.ino: -------------------------------------------------------------------------------- 1 | /* ********************************************************************** 2 | * 7-SegmentDisplay - v1.0 3 | * Uses Common cathode 7-segment display, 4 | * Uses 74HC595 shift register IC 5 | * 6 | * Inspired by Elegoo Lesson 27 www.elegoo.com 7 | * modified by Ricardo Moreno 8 | * 9 | * Description: 10 | * This sketch illustrates the controlling a 7-segment display with 11 | * a 74HC595 shift register. 12 | * 13 | * History: 14 | * 5/04/2019 v1.0 - Initial release 15 | * 16 | * define the LED digit patterns, from 0 - 9 17 | * 1 = LED on, 0 = LED off, common cathode, in this order: 18 | * 74HC595 pin Q7,Q6,Q5,Q4,Q3,Q2,Q1,Q0 19 | * Mapping to g,f,e,d,c,dp,a,b of Seven-Segment LED 20 | * ********************************************************* */ 21 | /* *********************************************************** 22 | * Global Constants * 23 | * Hardware Definitions * 24 | * ********************************************************* */ 25 | int latchPin = 11; // connect to the ST_CP of 74HC595 (pin 3,latch pin) 26 | int clockPin = 9; // connect to the SH_CP of 74HC595 (pin 4, clock pin) 27 | int dataPin = 12; // connect to the DS of 74HC595 (pin 2) 28 | 29 | byte sevenSegDigits[10] = { B01111011 , // = 0 30 | B00001001 , // = 1 31 | B10110011 , // = 2 32 | B10011011 , // = 3 33 | B11001001 , // = 4 34 | B11011010 , // = 5 35 | B11111000 , // = 6 36 | B00001011 , // = 7 37 | B11111011 , // = 8 38 | B11001011 // = 9 39 | }; 40 | byte sevenSegDP = B00000100; // = DP 41 | 42 | byte sevenSegAlpha[] = { B11101011 , // = A 43 | B11111000 , // = b 44 | B01110010 , // = C 45 | B10111001 , // = d 46 | B11110010 , // = E 47 | B11100010 , // = F 48 | B11011011 , // = g 49 | B11101000 , // = h 50 | B01100000 // = I 51 | }; 52 | /* *********************************************************** 53 | * Global Variables * 54 | * ********************************************************* */ 55 | bool bAddDecimalPoint = true; // display state of show decimal point 56 | 57 | /* *********************************************************** 58 | * Void setup * 59 | * ********************************************************* */ 60 | void setup() { 61 | // Set latchPin, clockPin, dataPin as output 62 | pinMode(latchPin, OUTPUT); 63 | pinMode(clockPin, OUTPUT); 64 | pinMode(dataPin, OUTPUT); 65 | } 66 | 67 | /* *********************************************************** 68 | * Functions * 69 | * ********************************************************* */ 70 | // display a alpha, binary value, or number on the digital segment display 71 | void sevenSegWrite(byte digit, bool bDP = false, char switchValue='D') { 72 | /* digit = array pointer or binary value, as a byte 73 | * bDP = true-include decimal point, as boolean 74 | * switchValue = 'A' alpha 75 | * 'B' binary 76 | * 'D' digits , as char */ 77 | 78 | // set the latchPin to low potential, before sending data 79 | digitalWrite(latchPin, LOW); 80 | 81 | // the data (bit pattern) 82 | if (switchValue=='A'){ 83 | // alpha 84 | shiftOut(dataPin, clockPin, MSBFIRST, sevenSegAlpha[digit]+(sevenSegDP*bDP)); 85 | } else if (switchValue=='B'){ 86 | // binary 87 | shiftOut(dataPin, clockPin, MSBFIRST, digit+(sevenSegDP*bDP)); 88 | } else { 89 | // digits 90 | shiftOut(dataPin, clockPin, MSBFIRST, sevenSegDigits[digit]+(sevenSegDP*bDP)); 91 | } 92 | 93 | // set the latchPin to high potential, after sending data 94 | digitalWrite(latchPin, HIGH); 95 | } 96 | 97 | void sevenSegBlank(){ 98 | // set the latchPin to low potential, before sending data 99 | digitalWrite(latchPin, LOW); 100 | shiftOut(dataPin, clockPin, MSBFIRST, B00000000); 101 | // set the latchPin to high potential, after sending data 102 | digitalWrite(latchPin, HIGH); 103 | } 104 | 105 | /* *********************************************************** 106 | * Void Loop * 107 | * ********************************************************* */ 108 | void loop() { 109 | //Switch add decimal point states 110 | bAddDecimalPoint = !bAddDecimalPoint; 111 | // count from 9 to 0 112 | // Change byte to int - byte doesn't have a negative number 113 | for (int digit = 9; digit >= 0; --digit) { 114 | sevenSegWrite(digit, bAddDecimalPoint); 115 | delay(1000); 116 | } 117 | // suspend 1 second 118 | sevenSegBlank(); 119 | delay(1000); 120 | 121 | // count from 0 to 9 122 | for (int digit = 0; digit <= 9; digit++) { 123 | sevenSegWrite(digit, bAddDecimalPoint); 124 | delay(1000); 125 | } 126 | // suspend 1 second 127 | sevenSegBlank(); 128 | delay(1000); 129 | 130 | // alpha characters 131 | for (int digit = 0; digit <= 8; digit++){ 132 | sevenSegWrite(digit, bAddDecimalPoint, 'A'); 133 | delay(1000); 134 | } 135 | // suspend 1 second 136 | sevenSegBlank(); 137 | delay(1000); 138 | 139 | // display individual segments - Binary 140 | sevenSegWrite(1,false,'B'); // B00000001 141 | delay(1000); 142 | sevenSegWrite(2,false,'B'); // B00000010 143 | delay(1000); 144 | sevenSegWrite(4,false,'B'); // B00000100 145 | delay(1000); 146 | sevenSegWrite(8,false,'B'); // B00001000 147 | delay(1000); 148 | sevenSegWrite(16,false,'B'); // B00010000 149 | delay(1000); 150 | sevenSegWrite(32,false,'B'); // B00100000 151 | delay(1000); 152 | sevenSegWrite(64,false,'B'); // B01000000 153 | delay(1000); 154 | sevenSegWrite(128,false,'B'); // B10000000 155 | delay(1000); 156 | 157 | // SECRET MESSAGE 158 | sevenSegWrite(0xE8,false,'B'); // B11101000 159 | delay(500); 160 | sevenSegWrite(0xF2,false,'B'); // B11110010 161 | delay(500); 162 | sevenSegWrite(0x70,false,'B'); // B01110000 163 | delay(500); 164 | sevenSegBlank(); // small blank flick 165 | delay(100); 166 | sevenSegWrite(0x70,false,'B'); // B01110000 167 | delay(500); 168 | sevenSegWrite(0xB8,false,'B'); // B10111000 169 | delay(500); 170 | sevenSegBlank(); 171 | delay(500); 172 | sevenSegWrite(0xD9,false,'B'); // B11011001 173 | delay(500); 174 | sevenSegWrite(0xB8,false,'B'); // B10111000 175 | delay(500); 176 | sevenSegWrite(0x38,false,'B'); // B00111000 177 | delay(500); 178 | sevenSegWrite(0xF0,false,'B'); // B11110000 179 | delay(500); 180 | sevenSegWrite(0x38,false,'B'); // B00111000 181 | delay(500); 182 | sevenSegWrite(0xF8,false,'B'); // B11111000 183 | delay(500); 184 | sevenSegWrite(0xF2,true,'B'); // B11110010 185 | delay(500); 186 | 187 | // suspend 1 second 188 | sevenSegBlank(); 189 | delay(1000); 190 | } 191 | -------------------------------------------------------------------------------- /Lesson 27 - 74HC595 and Segment Display/74HC595_7SegmentDisplay.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 27 - 74HC595 and Segment Display/74HC595_7SegmentDisplay.fzz -------------------------------------------------------------------------------- /Lesson 27 - 74HC595 and Segment Display/74HC595_7SegmentDisplay_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 27 - 74HC595 and Segment Display/74HC595_7SegmentDisplay_bb.png -------------------------------------------------------------------------------- /Lesson 27 - 74HC595 and Segment Display/74HC595_7SegmentDisplay_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 27 - 74HC595 and Segment Display/74HC595_7SegmentDisplay_schem.png -------------------------------------------------------------------------------- /Lesson 27 - 74HC595 and Segment Display/74HC595_SegmentDisplay.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 27 - 74HC595 and Segment Display/74HC595_SegmentDisplay.xlsx -------------------------------------------------------------------------------- /Lesson 27 - 74HC595 and Segment Display/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 27 - 74HC595 and Segment Display/README.md -------------------------------------------------------------------------------- /Lesson 28 - 4 Digit 7 Segment Display/4Digit_7SegmentDisplay.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 28 - 4 Digit 7 Segment Display/4Digit_7SegmentDisplay.xlsx -------------------------------------------------------------------------------- /Lesson 28 - 4 Digit 7 Segment Display/4_digit_proper.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 28 - 4 Digit 7 Segment Display/4_digit_proper.fzz -------------------------------------------------------------------------------- /Lesson 28 - 4 Digit 7 Segment Display/4_digit_proper_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 28 - 4 Digit 7 Segment Display/4_digit_proper_bb.png -------------------------------------------------------------------------------- /Lesson 28 - 4 Digit 7 Segment Display/4_digit_proper_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 28 - 4 Digit 7 Segment Display/4_digit_proper_schem.png -------------------------------------------------------------------------------- /Lesson 28 - 4 Digit 7 Segment Display/4digit7segment_PinLayout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 28 - 4 Digit 7 Segment Display/4digit7segment_PinLayout.png -------------------------------------------------------------------------------- /Lesson 28 - 4 Digit 7 Segment Display/5641AS_DataSheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 28 - 4 Digit 7 Segment Display/5641AS_DataSheet.pdf -------------------------------------------------------------------------------- /Lesson 28 - 4 Digit 7 Segment Display/Four_Digit_HexCounter/Four_Digit_HexCounter.ino: -------------------------------------------------------------------------------- 1 | /* ********************************************************************** 2 | * Four Digit Hex Counter 3 | * Uses: one 74HC595 shift register 4 | * one four digit seven segment display - common cathode (5641AS) 5 | * four PN2222 transistors 6 | * 7 | * Inspired by Elegoo Lesson 28 8 | * www.elegoo.com 2016.12.12 9 | * modified by Ricardo Moreno 10 | * 11 | * Description: 12 | * This sketch illustrates controlling a four digit 7-segment 13 | * display with a single 74HC595 shift register. Elegoo kit only 14 | * has one 74HC595, so the Arduino will control 7-segment pins D1-D4. 15 | * 16 | * History: 17 | * 6/06/2019 v1.0 - Initial release 18 | * 19 | * Verify circuit connections: 20 | * 74HC595 pin Q7,Q6,Q5,Q4,Q3,Q2,Q1,Q0 21 | * Mapping to g, c,DP, d, e, b, f, a (7-Segment LED) 22 | * for array purposes D4 = digit0, etc. 23 | ********************************************************************* */ 24 | 25 | /* *************************************************** 26 | * Global Constants * 27 | *************************************************** */ 28 | 29 | const int dataPin = 12; // 74HC595 pin 8 DS 30 | const int latchPin = 11; // 74HC595 pin 9 STCP 31 | const int clockPin = 9; // 74HC595 pin 10 SHCP 32 | const int digit0 = 7; // 7-Segment pin D4 33 | const int digit1 = 6; // 7-Segment pin D3 34 | const int digit2 = 5; // 7-Segment pin D2 35 | const int digit3 = 4; // 7-Segment pin D1 36 | 37 | /* *************************************************** 38 | * Global Variables * 39 | *************************************************** */ 40 | // Hex values reference which LED segments are turned on 41 | // and may vary from circuit to circuit. Note the mapping above. 42 | byte table[]= 43 | { 0x5F, // = 0 44 | 0x44, // = 1 45 | 0x9D, // = 2 46 | 0xD5, // = 3 47 | 0xC6, // = 4 48 | 0xD3, // = 5 49 | 0xDB, // = 6 50 | 0x45, // = 7 51 | 0xDF, // = 8 52 | 0xC7, // = 9 53 | 0xCF, // = A 54 | 0xDA, // = b 55 | 0x1B, // = C 56 | 0xDC, // = d 57 | 0x9B, // = E 58 | 0x8B, // = F 59 | 0x00 // blank 60 | }; //Hex shown 61 | byte digitDP = 32; // 0x20 - adds this to digit to show decimal point 62 | byte controlDigits[] = { digit0, digit1, digit2, digit3 }; // pins to turn off & on digits 63 | byte displayDigits[] = { 0,0,0,0,0 }; // ie: { 1, 0, 7, 13, 0} == d701 (all values from table array) 64 | /* Each array value holds digit values as table array index, or raw byte 65 | * parameters: digit0, digit1, digit2, digit3, digitSwitch 66 | * 67 | * digitSwitch: the four least significant bits controls data handling, 68 | * each bit controls associated digit 69 | * starting with least-significant bit 0, 70 | * i.e. B1010, digit1 & digit3 are raw, 71 | * digit0 & digit2 use table array 72 | * 1 = raw byte 73 | * 0 = table array index */ 74 | unsigned long onTime = 0; // tracks time 75 | bool switchView = false; // switch between HexCounter (table array) and RawDisplay (raw bytes) 76 | // false = HexCounter 77 | // true = RawDisplay 78 | unsigned int counter = 0; // RawDisplay counter 79 | 80 | /* *************************************************** 81 | * Global Adjustable Variables * 82 | *************************************************** */ 83 | int digitDelay = 50; // delay between incrementing digits (ms) 84 | int brightness = 90; // valid range of 0-100, 100=brightest 85 | unsigned int ShowSegCount = 250; // number of RawDisplay loops before switching again 86 | //bool commonCathode = true; 87 | 88 | /* *************************************************** 89 | * Void Setup * 90 | *************************************************** */ 91 | void setup() { 92 | //DDRD=0xff; // make pins 0-7 outputs 93 | //DDRB=0xff; // make pins 8-13 outputs 94 | //PORTD=0xf0; // make pins 4-7 HIGH 95 | 96 | pinMode(latchPin,OUTPUT); 97 | pinMode(clockPin,OUTPUT); 98 | pinMode(dataPin,OUTPUT); 99 | for (int x=0; x<4; x++){ 100 | pinMode(controlDigits[x],OUTPUT); 101 | digitalWrite(controlDigits[x],LOW); // Turns off the digit 102 | } 103 | } 104 | 105 | /* *************************************************** 106 | * Functions * 107 | *************************************************** */ 108 | void DisplaySegments(){ 109 | /* Display will send out all four digits 110 | * one at a time. Elegoo kit only has 1 74HC595, so 111 | * the Arduino will control the digits 112 | * displayDigits[4] = the right nibble controls output type 113 | * 1 = raw, 0 = table array 114 | * upper (left) nibble ignored 115 | * starting with 0, the least-significant (rightmost) bit 116 | */ 117 | 118 | for (int x=0; x<4; x++){ 119 | for (int j=0; j<4; j++){ 120 | digitalWrite(controlDigits[j],LOW); // turn off digits 121 | } 122 | digitalWrite(latchPin,LOW); 123 | if (bitRead(displayDigits[4],x)==1){ 124 | // raw byte value is sent to shift register 125 | shiftOut(dataPin,clockPin,MSBFIRST,displayDigits[x]); 126 | } else { 127 | // table array value is sent to the shift register 128 | shiftOut(dataPin,clockPin,MSBFIRST,table[displayDigits[x]]); 129 | } 130 | 131 | digitalWrite(latchPin,HIGH); 132 | digitalWrite(controlDigits[x],HIGH); // turn on one digit 133 | delay(1); // 1 or 2 is ok 134 | } 135 | for (int j=0; j<4; j++){ 136 | digitalWrite(controlDigits[j],LOW); // turn off digits 137 | } 138 | } 139 | 140 | void HexCounter(){ 141 | /* Increments values stored in displayDigits array to 142 | * creates a Hex counter from the table array. 143 | * Uses mixed display types: 144 | * Digit3 | Digit2 | Digit1 | Digit0 145 | * --------------------------------- 146 | * C | 0 | 0 | 0 147 | */ 148 | byte Letter = B00011011; // C 149 | 150 | //increment values for digits 0-2 151 | bool incrementValue = true; 152 | for (int d = 0; d < 3; d++){ 153 | int x = int(displayDigits[d]); 154 | if (incrementValue == true) { 155 | x++; 156 | incrementValue = false; 157 | if (x > 15) { 158 | displayDigits[d] = 0; 159 | incrementValue = true; 160 | } else { 161 | displayDigits[d] = byte(x); 162 | } 163 | } 164 | } 165 | // Set digit3 value 166 | displayDigits[3] = Letter; 167 | // Set digitSwitch option 168 | displayDigits[4] = B1000; 169 | 170 | if ((displayDigits[0] == 0)&&(displayDigits[1] == 0)&&(displayDigits[2] == 0)){ 171 | switchView = !switchView; 172 | for(int x = 0; x < 5; x++){ displayDigits[x]=0; } // Reset array 173 | displayDigits[4] = B0000; 174 | } 175 | } 176 | 177 | void RawDisplay(){ 178 | // HALO 179 | displayDigits[0] = B01011111; // 0 180 | displayDigits[1] = B00011010; // L 181 | displayDigits[2] = B11001111; // A 182 | displayDigits[3] = B11001110; // H 183 | // Set digitSwitch option 184 | displayDigits[4] = B1111; 185 | 186 | if (counter < ShowSegCount){ 187 | counter++; 188 | } else { 189 | // Reset everything 190 | counter = 0; 191 | switchView = !switchView; 192 | for(int x =0; x<5; x++){ displayDigits[x]=0; } // Reset array 193 | displayDigits[4] = B0000; 194 | } 195 | } 196 | 197 | /* *************************************************** 198 | * Void Loop * 199 | *************************************************** */ 200 | void loop() { 201 | 202 | DisplaySegments(); // Caution: Avoid extra delays 203 | 204 | /* ************************************* 205 | * Control Brightness * 206 | * *********************************** */ 207 | delayMicroseconds(1638*((100-brightness)/10)); // largest value 16383 208 | 209 | /* ************************************* 210 | * Selects Display Type * 211 | * *********************************** */ 212 | unsigned long nowValue = millis() - onTime; 213 | if (nowValue >= long(digitDelay)){ 214 | onTime = millis(); 215 | if(switchView==true){ RawDisplay(); } else { HexCounter(); } 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /Lesson 28 - 4 Digit 7 Segment Display/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 28 - 4 Digit 7 Segment Display/README.md -------------------------------------------------------------------------------- /Lesson 29 - DC Motors/DC_Motor.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 29 - DC Motors/DC_Motor.fzz -------------------------------------------------------------------------------- /Lesson 29 - DC Motors/DC_Motor/DC_Motor.ino: -------------------------------------------------------------------------------- 1 | /* ********************************************************************** 2 | * DC_Motor 3 | * Uses: one DC Motor 4 | * one L293D Quadruple half H-Bridge driver IC 5 | * one Breadboard Power Supply, MB-102 6 | * 7 | * Inspired by Elegoo Lesson 29 8 | * www.elegoo.com 2016.12.12 9 | * modified by Ricardo Moreno 10 | * 11 | * Description: 12 | * This sketch illustrates controlling a DC Motor using an 13 | * L293D Quadruple half H-Bridge driver IC. Note that the "D" 14 | * indicates inductive transient suppression diodes are 15 | * integrated in the IC. It's recommended that a separate 16 | * power supply is is used. 17 | * 18 | * Circuit: L293D 19 | * _______ 20 | * Arduino 5---EN12-| |-VCC1---5V 21 | * Ardunio 4-----1A-| |-4A 22 | * DCMotor+-----1Y-| |-4Y 23 | * GND--------| |--------GND 24 | * GND--------| |--------GND 25 | * DCMotor- ----2Y-| |-3Y 26 | * Arduino 3-----2A-| |-3A 27 | * 4.5-36V---VCC2-| |-EN34 28 | * ------- 29 | * History: 30 | * 6/16/2019 v1.0 - Initial release 31 | * 7/01/2019 v1.1 - Additional comments, minor rev to void loop 32 | * 33 | ********************************************************************* */ 34 | 35 | /* *************************************************** 36 | * Global Constants * 37 | *************************************************** */ 38 | const int Enable12 = 5; // PWM pin to L293D's EN12 (pin 1) 39 | const int Driver1A = 4; // To L293D's 1A (pin 2) 40 | const int Driver2A = 3; // To L293D's 2A (pin 7) 41 | 42 | /* *************************************************** 43 | * Global Variables * 44 | *************************************************** */ 45 | //none 46 | 47 | /* *************************************************** 48 | * Global Adjustable Variables * 49 | *************************************************** */ 50 | //none 51 | 52 | /* *************************************************** 53 | * Void Setup * 54 | *************************************************** */ 55 | void setup(){ 56 | //---set pin direction 57 | pinMode(Enable12,OUTPUT); 58 | pinMode(Driver1A,OUTPUT); 59 | pinMode(Driver2A,OUTPUT); 60 | Serial.begin(9600); 61 | } 62 | 63 | /* *************************************************** 64 | * Functions * 65 | *************************************************** */ 66 | void motorCTRL(byte speed, bool D1A, bool D2A){ 67 | /* motorCTRL controls the DC motor 68 | * speed: any value between 0-255, used as PWM 69 | * 0 - off 70 | * 255 - maximum 71 | * D1A: Input 1 or 1A, boolean value of HIGH or LOW 72 | * D2A: Input 2 or 2A, boolean value of HIGH or LOW 73 | */ 74 | analogWrite(Enable12,speed); // PWM 75 | digitalWrite(Driver1A,D1A); // Boolean 76 | digitalWrite(Driver2A,D2A); // Boolean 77 | } 78 | 79 | /* *************************************************** 80 | * Void Loop * 81 | *************************************************** */ 82 | void loop() { 83 | Serial.println("One way, then reverse"); 84 | //---back and forth example 85 | for (int i=0;i<5;i++){ 86 | motorCTRL(255,HIGH,LOW); // one way 87 | delay(500); 88 | motorCTRL(255,LOW,HIGH); // reverse 89 | delay(500); 90 | } 91 | motorCTRL(0,LOW,HIGH); // Stop 92 | delay(2000); 93 | 94 | Serial.println("fast Slow example"); 95 | //---fast/slow stop example 96 | motorCTRL(255,HIGH,LOW); // one way 97 | delay(3000); 98 | motorCTRL(0,HIGH,LOW); // slow stop 99 | delay(2000); 100 | motorCTRL(255,LOW,HIGH); // reverse 101 | delay(3000); 102 | motorCTRL(255,LOW,LOW); // fast stop 103 | delay(2000); 104 | 105 | Serial.println("PWM full then slow"); 106 | //---PWM example, full speed then slow 107 | for(int x = 255; x >= 55; x -= 25){ 108 | motorCTRL(x,HIGH,LOW); 109 | delay(1000); 110 | } 111 | motorCTRL(0,HIGH,LOW); // Stop 112 | delay(2000); 113 | 114 | Serial.println("PWM slow then full"); 115 | //---PWM example, slow then full speed 116 | for(int x = 55; x <= 255; x += 25){ 117 | motorCTRL(x,HIGH,LOW); 118 | delay(1000); 119 | } 120 | motorCTRL(0,HIGH,LOW); // Stop 121 | delay(10000); 122 | } 123 | 124 | -------------------------------------------------------------------------------- /Lesson 29 - DC Motors/DC_Motor_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 29 - DC Motors/DC_Motor_bb.png -------------------------------------------------------------------------------- /Lesson 29 - DC Motors/DC_Motor_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 29 - DC Motors/DC_Motor_schem.png -------------------------------------------------------------------------------- /Lesson 29 - DC Motors/Datasheet_pins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 29 - DC Motors/Datasheet_pins.png -------------------------------------------------------------------------------- /Lesson 29 - DC Motors/L293D_Pinout3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 29 - DC Motors/L293D_Pinout3.png -------------------------------------------------------------------------------- /Lesson 4 - RGB LED/Lesson4.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 4 - RGB LED/Lesson4.fzz -------------------------------------------------------------------------------- /Lesson 4 - RGB LED/Lesson4_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 4 - RGB LED/Lesson4_bb.png -------------------------------------------------------------------------------- /Lesson 4 - RGB LED/Lesson4_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 4 - RGB LED/Lesson4_schem.png -------------------------------------------------------------------------------- /Lesson 4 - RGB LED/README.md: -------------------------------------------------------------------------------- 1 | # ElegooTutorial 2 | 3 | ## Lesson 4 - RGB LED 4 | 5 | [Youtube Video](https://youtu.be/uNO4HSl6Ldw) 6 | 7 | A beginner's guide to the Most Complete Starter Kit by Elegoo. Lesson 4 – RGB LED 8 | 9 | Hello everyone, I'm Rick the Tech Enthusiast again, with the next Lesson number 4 “RGB LED”. This is the next lesson on my Arduino UNO Series covering the Most Complete Starter Kit by Elegoo. Now, I try to follow the tutorial closely, without overburdening the viewer with every detail, but I will point out any changes or corrections as I find them. 10 | 11 | As mentioned before, I recently purchased this Arduino UNO R3 kit by Elegoo. I’m pronouncing it El-E-Goo, I hope that’s right. No, Elegoo isn't sponsoring me. I just thought it would be fun to do a video of each Lesson as I was learning the Arduino environment. 12 | 13 | In this video, we’ll need a few things from your Elegoo Arduino kit. I’ll list the items below. In this lesson we’re going to learn how to change the colors of the RGB LED with the Arduino using PWM (pulse width modulation). I step through the Elegoo code to explain how it makes this happen. Then I expand on the idea with a revised sketch. The new sketch has three different methods of making colors with the RGB LED. The first method was inspired by HowToMechatronic.com. By using a function call we greatly simplify the code and make everything more readable. Next, I rewrite the three “for loops” that was included in the original code. And third, I create a single “do loop” or “do while loop” to cycle through all the colors in a single loop. Best of all, I’ve added Serial.begin and Serial.print statements to view and diagnose the code in the Serial Monitor. I hope you like the Lesson, it was a lot of fun to make. 14 | 15 | ## Parts you’ll need 16 | 17 | * Arduino UNO R3 board 18 | * RGB LED (the only LED in the kit with four leads) 19 | * Three 220 ohm resistors 20 | * Four male-to-male wire jumpers 21 | * Breadboard 22 | 23 | I should also mention that ** Paul McWhorter ** has a great [programming series for the Arduino UNO](https://www.youtube.com/watch?v=d8_xXNcGYgo&list=PLGs0VKk2DiYx6CMdOQR_hmJ2NbB4mZQn-). You should check it out. 24 | 25 | The next lesson will be Lesson 5 – Digital Inputs 26 | 27 | ## Links 28 | 29 | * Elegoo EL-KIT-001 UNO R3 Project Complete Starter Kit with Tutorial for Arduino (63 Items) 30 | * [Elegoo’s web site](https://www.elegoo.com/) 31 | * [Elegoo's Complete Starter Kit](https://www.amazon.com/gp/product/B01CZTLHGE/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B01CZTLHGE&linkCode=as2&tag=rmorenojr-20&linkId=ac3601531bad9439bc32c77b0088b741) - [web site](https://www.elegoo.com/product/elegoo-uno-r3-project-complete-starter-kit/) 32 | 33 | * [Frtizing Software](http://fritzing.org/download/) 34 | 35 | * [Arduino Language Reference](https://www.arduino.cc/reference/en/) 36 | 37 | * [LESSON 13: Controlling an RGB LED with Arduino](https://www.youtube.com/watch?v=gqAHOoqo3OI) – by Paul McWhorter 38 | * [HowToMechantronics](http://howtomechatronics.com/tutorials/arduino/how-to-use-a-rgb-led-with-arduino/) 39 | 40 | * Music provided by Free Music Archive, by artist [Jahzzar](http://freemusicarchive.org/search/?sort=track_date_published&d=1&quicksearch=jahzzar) 41 | 42 | This is the fifth video on a new Arduino tutorial series. If you like the series, be sure to rate and subscribe. 43 | 44 | Thanks for watching 45 | -------------------------------------------------------------------------------- /Lesson 4 - RGB LED/RGB_LED/RGB_LED.ino: -------------------------------------------------------------------------------- 1 | /* *********************************************************** 2 | * RGB_LED sketch - v1.0 3 | * Uses common cathode RGB LED 4 | * Arduino UNO R3 5 | * 6 | * Inspired by Elegoo Lesoon 4 - RGB LED 7 | * Included with The Most Complete Starter Kit by Elegoo 8 | * Original by - HowToMechatronics.com and Elegoo.com 9 | * Modified by - Ricardo Moreno 10 | * 11 | * Description: 12 | * This sketch illustrates a few ways to control the RGB LED 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 15 | * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 16 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 17 | * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * History: 24 | * 1/5/2018 - v1.0 initial release 25 | * 12/30/2019 - Minor comment and indent revisions to 26 | * improve readability. Moved Function setColor 27 | * to the top of the sketch. Renamed delayTime 28 | * to longDelay. 29 | * 30 | * ********************************************************* */ 31 | 32 | /* *********************************************************** 33 | * Global Constants * 34 | * Hardware Definitions * 35 | * ********************************************************* */ 36 | /* The Arduino Web site recommends that one uses const 37 | * rather than #define since using #define could have 38 | * unwanted side effects 39 | */ 40 | const int redPin = 6; // Red LED pin 41 | const int greenPin = 5; // Green LED pin 42 | const int bluePin = 3; // Blue LED pin 43 | const int maxBright = 255; // Maximum LED brightness 44 | 45 | /* *********************************************************** 46 | * Functions * 47 | * ********************************************************* */ 48 | void setColor(int redValue, int greenValue, int blueValue){ 49 | analogWrite(redPin, redValue); 50 | analogWrite(greenPin, greenValue); 51 | analogWrite(bluePin, blueValue); 52 | Serial.print("Red: "); 53 | Serial.print(redValue); 54 | Serial.print(" Green: "); 55 | Serial.print(greenValue); 56 | Serial.print(" Blue: "); 57 | Serial.println(blueValue); 58 | } 59 | 60 | /* *********************************************************** 61 | * Void Setup * 62 | * ********************************************************* */ 63 | void setup(){ 64 | Serial.begin(9600); //Turn On the Serial Port 65 | pinMode(redPin, OUTPUT); 66 | pinMode(greenPin, OUTPUT); 67 | pinMode(bluePin, OUTPUT); 68 | } 69 | 70 | /* *********************************************************** 71 | * Void Loop * 72 | * ********************************************************* */ 73 | void loop(){ 74 | //Local Variables 75 | int longDelay = 1000; // fading time between colors 76 | int shortDelay = 10; // short time delay between colors 77 | int redValue; 78 | int greenValue; 79 | int blueValue; 80 | int ledGear; // For switching LED fading 81 | 82 | //I combined various ways to turn on the RGB LED 83 | //Here we manually set the color 84 | Serial.println("Manual Colors"); 85 | setColor(maxBright, 0, 0); //Red Color 86 | delay(longDelay); 87 | setColor(0, maxBright, 0); //Green Color 88 | delay(longDelay); 89 | setColor(maxBright, maxBright, maxBright); //White Color 90 | delay(longDelay); 91 | setColor(170, 0, maxBright); //Purple Color 92 | delay(longDelay); 93 | 94 | Serial.println("Fade from Red to Green"); 95 | //Fade from Red to Green 96 | delay(longDelay); 97 | redValue = maxBright; 98 | greenValue = 0; 99 | blueValue = 0; 100 | for(int i = 0; i < maxBright+1; i++){ 101 | setColor(redValue, greenValue, blueValue); 102 | redValue -= 1; 103 | greenValue += 1; 104 | delay(shortDelay); 105 | } 106 | 107 | Serial.println("Fade from Green to Blue"); 108 | //Fade from Green to Blue 109 | delay(longDelay); 110 | redValue = 0; 111 | greenValue = maxBright; 112 | blueValue = 0; 113 | for(int i = 0; i < maxBright+1; i++){ 114 | setColor(redValue, greenValue, blueValue); 115 | greenValue -= 1; 116 | blueValue += 1; 117 | delay(shortDelay); 118 | } 119 | 120 | Serial.println("Fade from Blue to Red"); 121 | //Fade from Blue to Red 122 | delay(longDelay); 123 | redValue = 0; 124 | greenValue = 0; 125 | blueValue = maxBright; 126 | for(int i = 0; i < maxBright+1; i++){ 127 | setColor(redValue, greenValue, blueValue); 128 | blueValue -= 1; 129 | redValue += 1; 130 | delay(shortDelay); 131 | } 132 | 133 | Serial.println("Fade All three colors Red to Green, Green to Blue, Blue to Red"); 134 | //Fade All three colors Red to Green, Green to Blue, Blue to Red 135 | delay(longDelay); 136 | redValue = maxBright; 137 | greenValue = 0; 138 | blueValue = 0; 139 | ledGear = 1; 140 | do { 141 | setColor(redValue, greenValue, blueValue); 142 | //First Gear - Fade from Red to Green 143 | if (ledGear == 1) { 144 | redValue -= 1; 145 | greenValue += 1; 146 | } 147 | //Second Gear - Fade from Green to Blue 148 | if (ledGear == 2){ 149 | greenValue -= 1; 150 | blueValue += 1; 151 | } 152 | //Third Gear - Fade from Blue to Red 153 | if (ledGear == 3){ 154 | blueValue -= 1; 155 | redValue +=1; 156 | } 157 | //Gear Switching 158 | if (greenValue == maxBright) ledGear = 2; 159 | if (blueValue == maxBright) ledGear = 3; 160 | if (redValue == maxBright+1) ledGear = 4; 161 | delay(shortDelay); 162 | } while (ledGear < 4); 163 | delay(longDelay); 164 | } 165 | -------------------------------------------------------------------------------- /Lesson 5 - Digital Inputs/DigitalInput_Debounce/DigitalInput_Debounce.ino: -------------------------------------------------------------------------------- 1 | /* The Most Complete Starter Kit by Elegoo 2 | * For the Arduino UNO R3 3 | * LESSON 5 - Digital Input(s) 4 | * Single button with debounce function 5 | * 6 | * Original by - Applied Electronics, lynda.com, and Elegoo.com 7 | * Modified by - Ricardo Moreno 8 | * Date 1/9/2018 9 | * 10 | * Originally, the Lesson 5 sketch used two push button switches 11 | * to operate the LED. This sketch allows for a single push button 12 | * switch. 13 | * 14 | * Serial Monitor added for diagnostic purposes. 15 | * 16 | * Applied Electronics 17 | * https://www.youtube.com/watch?v=QslLAPNSEFc 18 | */ 19 | //usefull video to watch from educ8s.tv 20 | //https://www.youtube.com/watch?v=jYOYgU2vlSE 21 | 22 | // Global Variables 23 | const int ledPin = 5; 24 | const int buttonPin = 2; 25 | boolean lastButton = HIGH; //HIGH is the not pressed state 26 | boolean currentButton = HIGH; //HIGH is the not pressed state 27 | boolean ledOn = false; 28 | int counter = 0; 29 | 30 | // Sketch Setup routine - run once 31 | void setup(){ 32 | Serial.begin(9600); //starts the serial monitor and sets the baud rate 33 | pinMode(ledPin, OUTPUT); //sets the digital pin to output 34 | pinMode(buttonPin, INPUT_PULLUP); //define pinMode and use Pull-up resistor 35 | serialOut(ledOn,counter); //write the initial state of the LED 36 | } 37 | 38 | // main loop - runs repeatedly 39 | void loop(){ 40 | //Get button value or state 41 | currentButton = debounce(lastButton); 42 | 43 | //Recall that whenever you release the button, the state goes HIGH 44 | //When you press the button, you are forcing the state LOW 45 | if(lastButton == LOW && currentButton == HIGH){ 46 | //Button press detected 47 | counter += 1; //increment the counter 48 | ledOn = !ledOn; //shorthand way to switch to the opposite setting 49 | digitalWrite(ledPin, ledOn); //Turn ON or OFF the LED 50 | serialOut(ledOn,counter); //write the state of the LED and number of time the button has been pushed 51 | } 52 | lastButton = currentButton; 53 | } 54 | 55 | //Debouncing function 56 | boolean debounce(boolean last){ 57 | //Local Variable 58 | boolean current = digitalRead(buttonPin); 59 | 60 | if(last != current){ 61 | delay(5); //5 milliseconds 62 | current = digitalRead(buttonPin); 63 | } 64 | return current; 65 | } 66 | 67 | //Serial Output function 68 | void serialOut(boolean ledState, int i){ 69 | Serial.print("LED is "); 70 | if (ledState) Serial.print("ON - button pressed "); 71 | if (!ledState) Serial.print("OFF - button pressed "); 72 | Serial.print(i); 73 | Serial.println(" times"); 74 | } 75 | -------------------------------------------------------------------------------- /Lesson 5 - Digital Inputs/DigitalInput_Debounce/Lesson 5 Single Button Sketch.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 5 - Digital Inputs/DigitalInput_Debounce/Lesson 5 Single Button Sketch.fzz -------------------------------------------------------------------------------- /Lesson 5 - Digital Inputs/DigitalInput_Debounce/Lesson 5 Single Button Sketch_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 5 - Digital Inputs/DigitalInput_Debounce/Lesson 5 Single Button Sketch_bb.png -------------------------------------------------------------------------------- /Lesson 5 - Digital Inputs/DigitalInput_Debounce/Lesson 5 Single Button Sketch_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 5 - Digital Inputs/DigitalInput_Debounce/Lesson 5 Single Button Sketch_schem.png -------------------------------------------------------------------------------- /Lesson 5 - Digital Inputs/DigitalInput_DeepSleep/DigitalInput_DeepSleep.ino: -------------------------------------------------------------------------------- 1 | /* The Most Complete Starter Kit by Elegoo 2 | * For the Arduino UNO R3 3 | * LESSON 5 - Digital Input(s) 4 | * Using Interrupt, Low Power, Deep Sleep 5 | * 6 | * Original by - Kevin Darrah 7 | * Modified by - Ricardo Moreno 8 | * Date 1/10/2018 9 | * 10 | * Originally, the Lesson 5 sketch used two push button switches 11 | * to operate the LED. This sketch uses a single push button 12 | * switch activating an interrupt, waking up the Arduino. It runs the 13 | * code inside the void loop and automatically goes into a deep sleep. 14 | * It also has a watchdog timer to to automatically wake the circuit 15 | * every 8 seconds. 16 | * 17 | * Kevin Darrah does a great job flipping bits without the need for an 18 | * external library. He does an awesome job explaining this deep sleep setup. 19 | * 20 | * Serial Monitor added for diagnostic purposes. 21 | * 22 | * Kevin Darrah - Low Power Arduino! Deep Sleep Tutorial 23 | * https://www.youtube.com/watch?v=urLSDi7SD8M&t 24 | */ 25 | //Page of interest 26 | //https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/ 27 | 28 | // Global Variables 29 | const int ledPin = 5; 30 | const int buttonPin = 2; //Arduino UNO requires pins 2 or 3 31 | volatile int counter = 0; 32 | 33 | // Sketch Setup routine - run once 34 | void setup(){ 35 | Serial.begin(9600); //starts the serial monitor and sets the baud rate 36 | pinMode(buttonPin, INPUT_PULLUP); //define pinMode and use Pull-up resistor 37 | 38 | //Save Power by writing all Digital IO pins to LOW 39 | // Of course be carefull not to include pins you are using 40 | // not skipping LED pin is OK 41 | for (int i = 0; i < 20; i++) { 42 | if(i != buttonPin){ //we're using pin 2 for the button 43 | pinMode(i, OUTPUT); 44 | digitalWrite(i, LOW); 45 | } 46 | } 47 | //pinMode(ledPin, OUTPUT); //sets the digital pin to output - handled by above for loop 48 | 49 | /* attachInterrupt syntax 50 | * 51 | * attachInterrupt(interrupt, ISR, mode) 52 | * 53 | * interrupt can be either 0 or 1 for interrupts on pins 2 or 3. 54 | * recommend using the following code 55 | * digitalPinToInterrupt(pin) 56 | * 57 | * ISR Interrupt Service Routine - Name of a function 58 | * you want to execute after interrupt above 59 | * 60 | * mode� When the interrupt should be triggered. Options: 61 | * LOW a low level trigger 62 | * CHANGE a change in level trigger 63 | * RISING a rising edge of a level trigger 64 | * FALLING a falling edge of a level trigger 65 | * 66 | */ 67 | attachInterrupt(digitalPinToInterrupt(buttonPin), buttonInterrupt, RISING); 68 | serialOut(false, counter); //write the initial state of the LED 69 | 70 | /*SETUP WATCHDOG TIMER 71 | * This is set for about 8 seconds 72 | * See manufacturer's data sheet for other options 73 | * WDTCSR = 74 | * bits 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 75 | * WDIF | WDIE | WDP3 | WDCE | WDE | WDP2 | WDP1 | WDP0 76 | * 77 | * To enable and set the watchdog timer we must 78 | * set WDCE and WDE bits but 79 | * Also clears/resets prescaler bits WDP3,WDP2,WDP1,WDP0 80 | * See Watchdog Timer Control Register for more info 81 | * 24 = 00011000 82 | */ 83 | WDTCSR = (24); 84 | /* The above line must be followed by 85 | * Setting the prescalers bits WDP3,WDP2,WDP1,WDP0. 86 | * This gives us the 8 seconds based on table in data sheet. 87 | * We must also clear WDE and WDCE bits 88 | * 33 = 00100001 89 | */ 90 | WDTCSR = (33); 91 | // Now enable interrupt mode with new settings - set WDIE bit 92 | WDTCSR |= (1 << 6); //uses compound bitwise OR operator shift register trick 93 | 94 | /*Disable Analog to Digital Converter (ADC) 95 | * ADCSRA - ADC Control and Status Register A 96 | * Set the ADEN bit to 0 to turn off ADC 97 | * don't forget to flip back after waking up if using ADC 98 | * in your application ADCSRA |= (1 << 7); 99 | */ 100 | ADCSRA &= ~(1 << 7); //uses compound bitwise AND operator and inverted shift register trick 101 | 102 | /*ENABLE SLEEP MODE - 103 | * Sleep Mode Control Register 104 | * SMCR = 105 | * bits 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 106 | * - | - | - | - | SM2 | SM1 | SM0 | SE 107 | * bits 7-4 are unused 108 | * SE - Sleep Enable bit 109 | * 110 | * Sleep Mode Table 111 | * SM2 | SM1 | SM0 | Sleep Mode 112 | * 0 0 0 Idle 113 | * 0 0 1 ADC noise reduction 114 | * 0 1 0 Power-down 115 | * 0 1 1 Power-save 116 | * 1 1 0 Standby + 117 | * 1 1 1 External Standby + 118 | * + only recommended with external crystals or resonators 119 | * See manufacturer's data sheet for other options 120 | * 121 | * Using a technique to shift register bits 122 | * this enables the sleep mode 123 | * be sure to have an interrupt enabled or the 124 | * watchdog timer to wake it up 125 | */ 126 | //SET the sleep mode bit(s) 127 | SMCR |= (1 << 2); //power down mode 128 | SMCR |= 1; //enable sleep mode 129 | } 130 | 131 | // main loop - runs repeatedly 132 | void loop(){ 133 | Serial.println("Void loop starts"); 134 | digitalWrite(ledPin, HIGH); 135 | serialOut(true, counter); 136 | /* Put all you running code here 137 | * Once it's complete it will go 138 | * back to sleep. 139 | */ 140 | delay(1000); //delay not required 141 | digitalWrite(ledPin, LOW); 142 | serialOut(false, counter); 143 | 144 | goToSleep(); 145 | Serial.println("Void loop ends"); 146 | } 147 | 148 | void buttonInterrupt() { 149 | counter++; //increment the counter 150 | Serial.println("Button is pressed"); 151 | //This returns to the goToSleep or void loop 152 | } 153 | 154 | //Serial Output function 155 | void serialOut(boolean ledState, int i){ 156 | Serial.print("LED is "); 157 | if (ledState) Serial.print("ON - button pressed "); 158 | if (!ledState) Serial.print("OFF - button pressed "); 159 | Serial.print(i); 160 | Serial.println(" times"); 161 | } 162 | 163 | void goToSleep() { 164 | Serial.println("going to sleep"); 165 | delay(60); //small delay is necessary otherwise it goes to sleep before serial.println is done 166 | /*Disable the Brownout Detect circuit while sleeping 167 | * 168 | * this must be called right before the __asm__ sleep instruction 169 | * MCUCR - MCU Control Register 170 | * bits 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 171 | * - | BODS | BODSE | PUD | - | - | IVSEL | IVCE 172 | * 173 | * Set Both BODS and BODSE at the same time 174 | * 3 = 11 175 | */ 176 | MCUCR |= (3 << 5); 177 | //then set the BODS bit and clear the BODSE bit within 4 clock cycles 178 | //The trick below clears BODSE and sets BODS to 1 179 | MCUCR = (MCUCR & ~(1 << 5)) | (1 << 6); 180 | __asm__ __volatile__("sleep"); //in line assembler to go to sleep 181 | 182 | Serial.println("waking up"); 183 | } 184 | 185 | // watchdog interrupt 186 | ISR(WDT_vect){ 187 | Serial.println("Watch dog is on duty"); 188 | //DON'T FORGET THIS! Needed for the watch dog timer. 189 | // This is called after a watch dog timer timeout - 190 | // this is the interrupt function called after waking up 191 | } 192 | -------------------------------------------------------------------------------- /Lesson 5 - Digital Inputs/Lesson 5 Sketch.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 5 - Digital Inputs/Lesson 5 Sketch.fzz -------------------------------------------------------------------------------- /Lesson 5 - Digital Inputs/Lesson 5 Sketch_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 5 - Digital Inputs/Lesson 5 Sketch_bb.png -------------------------------------------------------------------------------- /Lesson 5 - Digital Inputs/Lesson 5 Sketch_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 5 - Digital Inputs/Lesson 5 Sketch_schem.png -------------------------------------------------------------------------------- /Lesson 5 - Digital Inputs/README.md: -------------------------------------------------------------------------------- 1 | # ElegooTutorial 2 | 3 | ## Lesson 5 – Digital Inputs 4 | 5 | A beginner's guide to the Most Complete Starter Kit by Elegoo. **Lesson 5 – Digital Inputs** 6 | 7 | [YouTube Video](https://www.youtube.com/watch?v=rbeHQ80dux8) 8 | 9 | Hello everyone, I'm Rick the Tech Enthusiast again, with the next Lesson number 5 “Digital Inputs”. This is the next lesson on my Arduino UNO Series covering the Most Complete Starter Kit by Elegoo. I try to follow the tutorial closely, without overburdening the viewer with every detail, but I will point out any changes or corrections as I find them. 10 | 11 | As mentioned before, I purchased this Elegoo starter kit. I’m pronouncing it El-E-Goo, I hope that’s right (I sometimes slip and say El-a-Goo). No, Elegoo isn't sponsoring me. I just thought it would be fun to do a video of each Lesson as I was learning the Arduino environment. 12 | 13 | For this video, we’ll need a few things from your Elegoo Arduino kit. I’ll list the items below. In this lesson we’re going to learn how to include digital inputs to your circuit using a couple of pushbutton switches. I step through the Elegoo provided code to explain how it makes this happen. Then, like before, I expand on the idea with a revised sketch. I wanted to provide a sketch that only uses a single button to turn on and off the LED. I also introduce the idea of debouncing the button input and how to handle it with code. And there more. I include yet another sketch, and this time it’s a circuit that turns on, and automatically goes to sleep when done. The watchdog timer is included to periodically wake the board. And a manual method in included to wake the circuit using a button and assigning to an Arduino interrupt. All while trying to achieve a very low power, deep sleep, mode. I got some great ideas from Kevin Darrah and Lynda.com 14 | 15 | Of course, I’ve added Serial.begin and Serial.print statements to view and diagnose the code in the Serial Monitor. I hope you like the Lesson, it was a lot of fun to make. 16 | 17 | ## Parts you’ll need for the basic tutorial 18 | 19 | * Arduino UNO R3 board 20 | * 5mm LED 21 | * 220 ohm resistor 22 | * Two pushbutton switches 23 | * Seven male-to-male wire jumpers 24 | * And the breadboard 25 | 26 | I should also mention that **Kevin Darrah** has a great [YouTube video](https://www.youtube.com/watch?v=urLSDi7SD8M) for the low power, deep sleep mode for the Arduino UNO. You should check it out. 27 | 28 | The next lesson will be Lesson 6 – Active Buzzer 29 | 30 | ## Links 31 | 32 | This lesson’s sketch and associated drawings can be found at [Github](https://github.com/rmorenojr/ElegooTutorial) 33 | 34 | * Elegoo EL-KIT-001 UNO R3 Project Complete Starter Kit with Tutorial for Arduino (63 Items) 35 | * [Elegoo’s web site](https://www.elegoo.com/) 36 | * [Elegoo's Complete Starter Kit](https://www.amazon.com/gp/product/B01CZTLHGE/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B01CZTLHGE&linkCode=as2&tag=rmorenojr-20&linkId=ac3601531bad9439bc32c77b0088b741) - [web site](https://www.elegoo.com/product/elegoo-uno-r3-project-complete-starter-kit/) 37 | 38 | * [Frtizing Software](http://fritzing.org/download/) 39 | 40 | * [Arduino Language Reference](https://www.arduino.cc/reference/en/) 41 | * [attachinterrupt](https//www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/) 42 | 43 | * [Applied Electronics](https://www.youtube.com/watch?v=QslLAPNSEFc) – **Lynda.com** 44 | 45 | * [educ8s.tv](https://www.youtube.com/watch?v=jYOYgU2vlSE) 46 | 47 | * [Kevin Darrah - Low Power Arduino! Deep Sleep Tutorial](https://www.youtube.com/watch?v=urLSDi7SD8M) 48 | 49 | This is the sixth video on a new Arduino tutorial series. If you like the series, be sure to rate and subscribe. 50 | 51 | Thanks for watching 52 | -------------------------------------------------------------------------------- /Lesson 5 - Digital Inputs/Script.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 5 - Digital Inputs/Script.pdf -------------------------------------------------------------------------------- /Lesson 6 - Active Buzzer/Lesson 6.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 6 - Active Buzzer/Lesson 6.fzz -------------------------------------------------------------------------------- /Lesson 6 - Active Buzzer/Lesson 6_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 6 - Active Buzzer/Lesson 6_bb.png -------------------------------------------------------------------------------- /Lesson 6 - Active Buzzer/Lesson 6_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 6 - Active Buzzer/Lesson 6_schem.png -------------------------------------------------------------------------------- /Lesson 6 - Active Buzzer/MorseCode_Translator/Morse Code Translator.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 6 - Active Buzzer/MorseCode_Translator/Morse Code Translator.fzz -------------------------------------------------------------------------------- /Lesson 6 - Active Buzzer/MorseCode_Translator/Morse Code Translator_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 6 - Active Buzzer/MorseCode_Translator/Morse Code Translator_bb.png -------------------------------------------------------------------------------- /Lesson 6 - Active Buzzer/MorseCode_Translator/Morse Code Translator_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 6 - Active Buzzer/MorseCode_Translator/Morse Code Translator_schem.png -------------------------------------------------------------------------------- /Lesson 6 - Active Buzzer/MorseCode_Translator/MorseCode_Translater/MorseCode_Translater.ino: -------------------------------------------------------------------------------- 1 | /* *********************************************************** 2 | * Morse Code Translater 3 | * By Ricardo Moreno Jr. 4 | * created 01/15/2018 5 | * 6 | * Inspired by learnelectronics 7 | * https://www.youtube.com/watch?v=3WjNiJOcVaM 8 | * Nick B 9 | * https://pastebin.com/SM9jmjdG 10 | * 11 | * From Wikipedia 12 | * length of a dot is 1 unit 13 | * length of a dash is 3 units 14 | * length of a space between parts of the same letter is 1 unit 15 | * length of a space between letters is 3 units 16 | * length of a space between words is seven units 17 | * 18 | * The Dot or Dash are commonly referred to as Dit or Dah 19 | * 20 | * History: 21 | * 1/15/2018 v1.0 - Initial release 22 | * 11/29/2020 V1.1 - Revised comments and indenting for readability. 23 | * Added detect Line Feed character in doString function 24 | * - thx peterlution 25 | * *********************************************************** */ 26 | 27 | /* *********************************************************** 28 | * Global Constants * 29 | * Hardware Definitions * 30 | * ********************************************************* */ 31 | const int buzzerPin = 12; // set buzzer pin 32 | const int ledPin = 6; // set LED pin 33 | 34 | /* *********************************************************** 35 | * Global Variables * 36 | * ********************************************************* */ 37 | String strInput = ""; 38 | 39 | // Morse Code Specific delays 40 | int mcUnit = 75; // length of time in milliseconds 41 | // mcUnit is the only value that 42 | // needs adjusting 43 | int dit = mcUnit; // dit equals 1 unit of time 44 | int dah = 3 * mcUnit; // dah equals 3 units of time 45 | int partsDelay = mcUnit; // 1 unit between parts 46 | int letterDelay = 3 * mcUnit; // 3 units between letters 47 | int wordDelay = 7 * mcUnit; // 7 units between words 48 | 49 | /* *********************************************************** 50 | * Global Arrays * 51 | * ********************************************************* */ 52 | // Recall Arrays start from 0 53 | String letters[] = { 54 | ".-", "-...", "-.-.", "-..", // A-D 55 | ".", "..-.", "--.", "....", // E-H 56 | "..", ".---", "-.-", ".-..", // I-L 57 | "--", "-.", "---", ".--.", // M-P 58 | "--.-", ".-.", "...", "-", // Q-T 59 | "..-", "...-", ".--", "-..-", // U-X 60 | "-.--", "--.." // Y-Z 61 | }; 62 | 63 | String numbers[] = { 64 | "-----", ".----", "..---", // 0-2 65 | "...--", "....-", ".....", // 3-5 66 | "-....", "--...", "---..", // 6-8 67 | "----." // 9 68 | }; 69 | 70 | String Lpunctuation[] = { 71 | "-.-.--", // ! -33 72 | ".-..-.", // " -34 73 | "X", // # -35 74 | "...-..-", // $ -36 75 | "X", // % -37 76 | ".-...", // & -38 77 | ".----.", // ' -39 78 | "-.--.", // ( -40 79 | "-.--.-", // ) -41 80 | "X", // * -42 81 | ".-.-.", // + -43 82 | "X", // , -44 83 | "-....-", // - -45 84 | ".-.-.-", // . -46 85 | "-..-.", // / -47 86 | }; 87 | 88 | String Upunctuation[] = { 89 | "---...", // : -58 90 | "-.-.-.", // ; -59 91 | "X", // < -60 92 | "-...-", // = -61 93 | "X", // > -62 94 | "..--..", // ? -63 95 | ".--.-." // @ -64 96 | }; 97 | 98 | String SpecialCase[] = { 99 | "_", "..--.-", // _ -95 100 | }; 101 | 102 | // Not included yet 103 | String ProSigns[] = { 104 | "...-.-", // End Of Work 105 | "........", // Error 106 | "-.-", // Invitation to Transmit - K 107 | "-.-.-", // Starting Signal 108 | ".-.-.", // New Page Signal - + 109 | "...-.", // Understood - also Ŝ 110 | ".-..." // Wait - also & 111 | }; 112 | 113 | /* *********************************************************** 114 | * Void setup * 115 | * ********************************************************* */ 116 | void setup() { 117 | // setup code here, runs once 118 | Serial.begin(9600); // Used for Serial Monitor 119 | pinMode(buzzerPin, OUTPUT); // set buzzer pin, OUTPUT automatically sets it to LOW 120 | pinMode(ledPin, OUTPUT); // set LED pin, OUTPUT automatically sets it to LOW 121 | } 122 | 123 | /* *********************************************************** 124 | * Functions * 125 | * ********************************************************* */ 126 | void DitOrDah(int DitOrDahDelay){ 127 | /* This function turns ON and OFF the LED 128 | * and Active Buzzer by the delay value 129 | * passed to it. 130 | */ 131 | digitalWrite(buzzerPin, HIGH); 132 | digitalWrite(ledPin, HIGH); 133 | delay(DitOrDahDelay); // dit or dah delay 134 | digitalWrite(buzzerPin, LOW); 135 | digitalWrite(ledPin, LOW); 136 | } 137 | 138 | void doSequence(String sequence){ 139 | // Local Variables 140 | int strLen = 0; 141 | char chValue = ""; 142 | 143 | strLen = sequence.length(); // get length of string 144 | //note: last char is a NULL 145 | for (int x = 0; x < strLen; x++){ // loop through all parts 146 | chValue = sequence.charAt(x); // get char value 147 | if(chValue == '.'){ 148 | DitOrDah(dit); // do a Dit 149 | Serial.print("."); // print dit 150 | } 151 | else if (chValue == '-'){ 152 | DitOrDah(dah); // do a Dah 153 | Serial.print("-"); // print dah 154 | } 155 | else if (chValue == 'X'){ // No translation 156 | Serial.print("X - no translation"); // print no translation 157 | } 158 | else if (int(chValue) == 0){ // Null char in string 159 | // Null found // May not be needed 160 | // Do Nothing // should be skipped 161 | } // end if statement 162 | 163 | if (x < strLen) delay(partsDelay); // gap between parts 164 | } // end for 165 | Serial.println(""); 166 | } // end doSequence 167 | 168 | void translate(char ch){ 169 | /* Recall that letters have a numeric ASCII value 170 | * so you can add and substract them 171 | * a = 97 172 | * A = 65 173 | * 0 = 48 174 | * 175 | * Modify this function for additonal character checks 176 | * ASCII numerical order below (mostly) 177 | */ 178 | if (ch >= '!' && ch <= '/'){ 179 | Serial.print(ch); 180 | Serial.print(" "); 181 | doSequence(Lpunctuation[ch - '!']); 182 | } else if (ch >= '0' && ch <= '9'){ 183 | Serial.print(ch); 184 | Serial.print(" "); 185 | doSequence(numbers[ch - '0']); 186 | } else if (ch >= ':' && ch <= '@'){ 187 | Serial.print(ch); 188 | Serial.print(" "); 189 | doSequence(Upunctuation[ch - ':']); 190 | } else if (ch >= 'A' && ch <= 'Z'){ 191 | Serial.print(ch); 192 | Serial.print(" "); 193 | doSequence(letters[ch - 'A']); 194 | } else if (ch >= 'a' && ch <= 'z'){ 195 | Serial.print(ch); 196 | Serial.print(" "); 197 | doSequence(letters[ch - 'a']); 198 | } else if (ch == '_'){ 199 | Serial.print(ch); 200 | Serial.print(" "); 201 | doSequence(SpecialCase[1]); 202 | } else { 203 | Serial.println("invalid character"); 204 | // Skip invalid character 205 | } // end if statement 206 | } // end translate 207 | 208 | void doString(String strValue){ 209 | // Local Variables 210 | char chValue; 211 | int strLen = 0; 212 | 213 | strLen = strValue.length(); // get the length of the string 214 | 215 | for(int x = 0; x <= strLen; x++){ // loop through string to get each value 216 | chValue = strInput.charAt(x); // get char at position x 217 | 218 | if (chValue == " " || int(chValue) == 32){// Found Space between words 219 | Serial.println("(space)"); 220 | delay(wordDelay); // delay between words 221 | } else if (int(chValue) == 13){ // Carrige Return found 222 | // Do Nothing 223 | } else if (int(chValue) == 10){ // Line feed found 224 | // Do Nothing 225 | } else if (int(chValue) == 0){ // Null found 226 | // Do Nothing 227 | } else { 228 | translate(chValue); // translate character to Morse Code 229 | if (x < strLen) delay(letterDelay); // delay between letters 230 | } // end if 231 | } // end for 232 | } // end doString 233 | 234 | /* *********************************************************** 235 | * Void Loop * 236 | * ********************************************************* */ 237 | void loop(){ 238 | // main code here, runs repeatedly 239 | Serial.println("Enter a string you want to translate to Morse Code"); 240 | 241 | // Use the Serial Monitor to input a message 242 | while (Serial.available() == 0){ 243 | // Do Nothing // Wait until user input 244 | } 245 | strInput = Serial.readString(); // get the new String 246 | Serial.print(" Translating => "); 247 | Serial.println(strInput); // print string to serial monitor 248 | doString(strInput); // go to doString function 249 | 250 | delay(1000); // delay between loops 251 | Serial.println(""); // Add a new line feed to serial monitor 252 | strInput=""; // clear the string 253 | } 254 | 255 | 256 | -------------------------------------------------------------------------------- /Lesson 6 - Active Buzzer/README.md: -------------------------------------------------------------------------------- 1 | # ElegooTutorial 2 | 3 | ## Lesson 6 – Active Buzzer and Morse Code Translator 4 | 5 | [YouTube Video](https://youtu.be/RKejZWnCWx8) 6 | 7 | A beginner's guide to the Most Complete Starter Kit by Elegoo. **Lesson 6 – Active Buzzer** 8 | 9 | Hello everyone, I'm Rick the Tech Enthusiast again, with the next Lesson number 6 “Active Buzzer”. This is the next lesson on my Arduino UNO Series covering the Most Complete Starter Kit by Elegoo. I try to follow the tutorial closely, without overburdening the viewer with every detail, but I will point out any changes or corrections as I find them. 10 | 11 | As mentioned before, I purchased this Elegoo starter kit. I’m pronouncing it El-E-Goo, I hope that’s right (I sometimes slip and say El-a-Goo). No, Elegoo isn't sponsoring me. I just thought it would be fun to do a video of each Lesson as I was learning the Arduino environment. 12 | 13 | For this video, we’ll need a few things from your Elegoo Arduino kit. I’ll list the items below. In this lesson we’re going to learn what an active buzzer is and how to use them in our projects. I step through the Elegoo provided code to explain how it makes this happen. The pulsating tone makes a great pet scaring circuit. And as I was just about to finish the video, I got this idea on making a Morse Code Translator circuit. The Morse Code Translator circuit used the active buzzer, LED, couple of resistors and a few jumpers to the Arduino. The code is a little more advanced, so I’ve included some additional links below that covers some of the topics. Now, I have to admit that I use my phone to record all the live video shots, and I have to sync them up in my editor. Which is Movie Maker for Windows (cue the sad trombone). It was a challenge to mesh the screen capture and live capture together. But I assure you that the code works. I like to thank learnelectronics and Nick B for inspiring me to create the Morse Code Sketch. And the Programming Electronics Academy has a great video “An easy way to make noise with Arduino using tone()”, which may apply more towards the next lesson but he has a fantastic piezo buzzer explanation. 14 | 15 | Of course, I’ve added Serial.begin, Serial.print, and Serial.read statements to view and diagnose the code in the Serial Monitor. I hope you like the Lesson, it was a lot of fun to make. 16 | 17 | ## Parts you’ll need for the basic tutorial 18 | 19 | * Arduino UNO R3 board 20 | * Active Buzzer (that the one with a white sticker on it) 21 | * Two female-to-male wire jumpers 22 | 23 | The next lesson will be **Lesson 7 – Passive Buzzer** 24 | 25 | ## Links 26 | 27 | This lesson’s sketch and associated drawings can be found at [Github](https://github.com/rmorenojr/ElegooTutorial) 28 | 29 | 30 | * Cylewet 10Pcs 5V 2 Terminals Passive Electronic Alarm Buzzer Electromagnetic Beeper AC Impedance for Arduino (Pack of 10) CYT1008 31 | * Elegoo EL-KIT-001 UNO R3 Project Complete Starter Kit with Tutorial for Arduino (63 Items) 32 | * [Elegoo’s web site](https://www.elegoo.com/) - [Complete Starter Kit](https://www.elegoo.com/product/elegoo-uno-r3-project-complete-starter-kit/) 33 | 34 | * [Fritzing Software](http://fritzing.org/download/) 35 | 36 | * [Arduino Language Reference (English)](https://www.arduino.cc/reference/en/) 37 | * [attachinterrupt](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/) 38 | * [Arduino ASCII chart](https://www.arduino.cc/en/Reference/ASCIIchart) 39 | 40 | * [Morse Code - Wikipedia.org](https://en.wikipedia.org/wiki/Morse_code) 41 | * [Arduino Morse Code Translator](https://www.youtube.com/watch?v=3WjNiJOcVaM) - by learnelectronics 42 | * [Arduino Morse Code Translator](https://pastebin.com/SM9jmjdG) - Nick B 43 | * Great piezo buzzer explanation - [An easy way to make noise with Arduino using tone()](https://www.youtube.com/watch?v=1_LMAgO14z0&t) - Programming Electronics Academy 44 | * [LESSON 12: Simple and Easy Way to Read Strings Floats and Ints over Arduino Serial Port](https://www.youtube.com/watch?v=VIa_QZWIonQ) - Paul McWhorter 45 | 46 | * Music provided by Free Music Archive, by artist **Jahzzar** - [Jahzzar_-_07_-_maniac](http://freemusicarchive.org/music/Jahzzar/) 47 | 48 | This is the seventh video on a new Arduino tutorial series. If you like the series, be sure to rate and subscribe. 49 | 50 | Thanks for watching 51 | -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/Lesson7.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 7 - Passive Buzzer/Lesson7.fzz -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/Lesson7_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 7 - Passive Buzzer/Lesson7_bb.png -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/Lesson7_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 7 - Passive Buzzer/Lesson7_schem.png -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/MusicPlayer.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 7 - Passive Buzzer/MusicPlayer.fzz -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/MusicPlayer2.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 7 - Passive Buzzer/MusicPlayer2.fzz -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/MusicPlayer2_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 7 - Passive Buzzer/MusicPlayer2_bb.png -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/MusicPlayer2_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 7 - Passive Buzzer/MusicPlayer2_schem.png -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/MusicPlayer_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 7 - Passive Buzzer/MusicPlayer_bb.png -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/MusicPlayer_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 7 - Passive Buzzer/MusicPlayer_schem.png -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/README.md: -------------------------------------------------------------------------------- 1 | # ElegooTutorial 2 | 3 | ## Lesson 7 – Passive Buzzer and Happy Birthday, Imperial March, and Super Mario melody player with 3-Way Polyphony 4 | 5 | [YouTube video](https://youtu.be/X-3AoN8Subk) 6 | 7 | A beginner's guide to the Most Complete Starter Kit by Elegoo. **Lesson 7 – Passive Buzzer** 8 | 9 | Hello everyone, I'm Rick the Tech Enthusiast here with the next Lesson number 7 “Passive Buzzer”. This is the next lesson on my Arduino UNO Series covering the Most Complete Starter Kit by Elegoo. I try to follow the tutorial closely, without overburdening the viewer with every detail, but I will point out any changes or corrections as I find them. 10 | 11 | As mentioned before, I purchased this Elegoo starter kit. I’m pronouncing it El-E-Goo, I hope that’s right (I sometimes slip and say El-a-Goo). No, Elegoo isn't sponsoring me. I just thought it would be fun to do a video of each Lesson as I was learning the Arduino environment. 12 | 13 | For this video, we’ll need a few things from your Elegoo Arduino kit. I’ll list the items below. In this lesson we’re going to learn what a passive buzzer is and how to use them in our projects. I step through the Elegoo provided code to explain how it makes this happen. I also ran into some problems with what was recommended from piezo manufacturers, and other web sites, with what’s provided in the tutorial. So I explain my findings, and restart the tutorial. I even revise the provided sketch to include a scale that plays up and down. For bonus material, I created a music player inspired by the Happy Birthday Melody for the Nano with 3-way Polyphony by Liss. I use the prototype board and mini breadboard that’s included in the kit. I did have to purchase additional passive buzzers to make this work (links below). I quickly take you through the changes in the code and play the Happy Birthday melody in 3-Way Polyphony. I repeated this for the Star Wars Imperial March (not Polyphony), and Super Mario theme melodies. Sorry, I did ramble a few times. But overall, I had a blast and maybe I’ll revisit the project in the future. 14 | 15 | I hope you like the Lesson, it was a lot of fun to make. 16 | 17 | ## Parts you’ll need for the basic tutorial 18 | 19 | * Arduino UNO R3 board 20 | * Passive Buzzer (that the one without a white sticker on it – you’ll need two more if you want to do the bonus sketch) 21 | * One diode (5 are provided in the kit) 22 | * One 100-ohm resistor 23 | * Several jumpers 24 | * Breadboard 25 | 26 | ## The Bonus Music Player parts 27 | 28 | * Arduino UNO R3 board 29 | * Three passive buzzers (links are provided below) 30 | * Three 100-ohm resistors 31 | * Three 1N4007 diode 32 | * 5mm Red LED 33 | * 5mm Yellow LED 34 | * 5mm Green LED 35 | * Three 220-ohm resistors 36 | * Various jumper wires 37 | * Mini breadboard 38 | * Elegoo prototype board 39 | 40 | The next lesson will be **Lesson 8 – Tilt Ball Switch and the Magic 8-Ball** 41 | 42 | ## Links 43 | 44 | This lesson’s sketch and associated drawings can be found at [Github](https://github.com/rmorenojr/ElegooTutorial) 45 | 46 | 47 | * Cylewet 10Pcs 5V 2 Terminals Passive Electronic Alarm Buzzer Electromagnetic Beeper AC Impedance for Arduino (Pack of 10) CYT1008 48 | 49 | * Elegoo EL-KIT-001 UNO R3 Project Complete Starter Kit with Tutorial for Arduino (63 Items) 50 | * [Elegoo’s web site](https://www.elegoo.com/) - [Complete Starter Kit](https://www.elegoo.com/product/elegoo-uno-r3-project-complete-starter-kit/) 51 | 52 | * [Fritzing Software](http://fritzing.org/download/) 53 | 54 | * [Arduino Language Reference (English)](https://www.arduino.cc/reference/en/) 55 | * [attachinterrupt](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/) 56 | * [Arduino tone() function](https://www.arduino.cc/reference/en/language/functions/advanced-io/tone/) 57 | * [Arduino Playing tones on Multiple outputs using the tone() function](https://www.arduino.cc/en/Tutorial/ToneMultiple) 58 | 59 | * [Tone.h library](https://github.com/bhagman/Tone) 60 | * [An easy way to make noise with Arduino using tone()](https://www.youtube.com/watch?v=1_LMAgO14z0&t) - by Programming Electronics Academy 61 | * Great piezo buzzer explanation [An easy way to make noise with Arduino using tone()](https://www.youtube.com/watch?v=1_LMAgO14z0&t) - Programming Electronics Academy 62 | * [Happy Birthday Melody on Arduino Nano With 3-way Polyphony](https://www.hackster.io/liss/happy-birthday-melody-on-arduino-nano-with-3-way-polyphony-c80c31) by Liss 63 | * [Arduino + Star Wars Imperial March (Buzzer/Piezo)](https://www.youtube.com/watch?v=83xHpj3PstI) by Profe-Electro 64 | * [Super Mario Bros. Overworld Theme (old version)](https://pastebin.com/AKR5VL87) by Ignacio Castillo Álvarez 65 | * [Overworld / Main Theme](http://www.mariopiano.com/midi-sound-file-overworld-main-theme.html) by mariopiano.com 66 | 67 | * Music provided by Free Music Archive, by artist Jahzzar - [Jahzzar_-_12_-_Birthday_Cake](http://freemusicarchive.org/music/Jahzzar/) 68 | 69 | This is another video for my new Arduino tutorial series. If you like the series, be sure to rate and subscribe. 70 | 71 | Thanks for watching 72 | -------------------------------------------------------------------------------- /Lesson 7 - Passive Buzzer/StarWarsImperialMarch/StarWarsImperialMarch.ino: -------------------------------------------------------------------------------- 1 | /* Arduino + Star Wars Imperial March (Buzzer/Piezo) 2 | * Modified by Ricardo Moreno 3 | * https://github.com/rmorenojr/ElegooTutorial 4 | * 01/21/2018 5 | * 6 | * Original by Profe-Electro 7 | * https://www.youtube.com/watch?v=83xHpj3PstI 8 | */ 9 | #include 10 | 11 | //Global Constants 12 | const int melodyBuzzerPin = 6; // Digital Pin 8 13 | const int leftLedPin = 19; // Analog Pin A5 14 | const int rightLedPin = 17; // Analog Pin A3 15 | 16 | /* I couldn't figure out the timing of this score 17 | * perhaps I'll revise it in the future 18 | * Imperial March 19 | * Ala Marcia 1/4 note = 112 on sheet music 20 | * https://www.youtube.com/watch?v=4pwcsn0TU0Q 21 | */ 22 | // Timing 23 | const int t4 = 125; // quarter note duration in ms 24 | const int td4 = t4*1.5; // dotted quarter note 25 | const int tL4 = t4*1.3; // Legato quarter note 26 | const int t2 = t4*2; // half note 27 | const int td2 = t4*3; // dotted half note 28 | const int tL2 = t2*1.3; // Legato half note 29 | const int wt = t4*4; // whole note 30 | const int wtL = wt*1.3; // whole note 31 | const int t16 = round(t4*1/4); // 1/16 note 32 | const int t8 = round(t4*1/2); // 1/8 note 33 | const int tL8 = round(t8*1.3); // Legato 1/8 note 34 | const int td8 = round(t8*1.5); // dotted 1/8 note 35 | const int ts8 = round(t8*.8); // Stacatto 1/8 note 36 | 37 | boolean FlipFlop = true; // LED state 38 | 39 | void setup(){ 40 | //Setup pin modes 41 | pinMode(melodyBuzzerPin, OUTPUT); 42 | pinMode(leftLedPin, OUTPUT); 43 | pinMode(rightLedPin, OUTPUT); 44 | } 45 | 46 | void loop(){ 47 | //Play first section 48 | firstSection(); 49 | 50 | //Play second section 51 | secondSection(); 52 | 53 | //Variant 1 54 | beep(NOTE_F4, t2); 55 | beep(NOTE_GS4, wt); 56 | beep(NOTE_F4, tL2); 57 | beep(NOTE_A4, t4); 58 | beep(NOTE_C5, wt); 59 | beep(NOTE_A4, td2); 60 | beep(NOTE_C5, t4); 61 | beep(NOTE_E5, wtL); 62 | 63 | delay(wt); 64 | 65 | //Repeat second section 66 | secondSection(); 67 | 68 | //Variant 2 69 | beep(NOTE_F4, t2); 70 | beep(NOTE_GS4, wt); 71 | beep(NOTE_F4, td2); 72 | beep(NOTE_C5, t4); 73 | beep(NOTE_A4, wt); 74 | beep(NOTE_F4, td2); 75 | beep(NOTE_C5, t4); 76 | beep(NOTE_A4, wtL); 77 | 78 | delay(wtL); 79 | } 80 | 81 | /* *********************************************************** 82 | * Functions 83 | * *********************************************************** */ 84 | 85 | void beep(int note, int duration){ 86 | //Play tone on melodyBuzzerPin 87 | tone(melodyBuzzerPin, note, duration); 88 | 89 | if(FlipFlop){ 90 | digitalWrite(leftLedPin, HIGH); 91 | } 92 | else { 93 | digitalWrite(rightLedPin, HIGH); 94 | } 95 | delay(duration); 96 | digitalWrite(leftLedPin, LOW); 97 | digitalWrite(rightLedPin, LOW); 98 | FlipFlop = !FlipFlop; 99 | 100 | //Stop tone on melodyBuzzerPin 101 | noTone(melodyBuzzerPin); 102 | 103 | delay(ts8); 104 | } 105 | 106 | void firstSection(){ 107 | beep(NOTE_A4, wt); 108 | beep(NOTE_A4, wt); 109 | beep(NOTE_A4, wt); 110 | beep(NOTE_F4, tL2); 111 | beep(NOTE_C5, tL4); 112 | beep(NOTE_A4, wt); 113 | beep(NOTE_F4, tL2); 114 | beep(NOTE_C5, tL4); 115 | beep(NOTE_A4, wtL); 116 | 117 | delay(wt); 118 | 119 | beep(NOTE_E5, wt); 120 | beep(NOTE_E5, wt); 121 | beep(NOTE_E5, wt); 122 | beep(NOTE_F5, tL2); 123 | beep(NOTE_C5, tL4); 124 | beep(NOTE_GS4, wt); 125 | beep(NOTE_F4, tL2); 126 | beep(NOTE_C5, tL4); 127 | beep(NOTE_A4, wtL); 128 | 129 | delay(wt); 130 | } 131 | 132 | void secondSection(){ 133 | beep(NOTE_A5, wt); 134 | beep(NOTE_A4, tL2); 135 | beep(NOTE_A4, tL4); 136 | beep(NOTE_A5, wt); 137 | beep(NOTE_GS5, tL2); 138 | beep(NOTE_G5, td4); 139 | beep(NOTE_FS5, t4); 140 | beep(NOTE_F5, t4); 141 | beep(NOTE_FS5, t2); 142 | 143 | delay(tL2); 144 | 145 | beep(NOTE_AS4, t2); 146 | beep(NOTE_DS5, wt); 147 | beep(NOTE_D5, tL2); 148 | beep(NOTE_CS5, td4); 149 | beep(NOTE_C5, t4); 150 | beep(NOTE_B4, t4); 151 | beep(NOTE_C5, t2); 152 | 153 | delay(tL2); 154 | } 155 | 156 | -------------------------------------------------------------------------------- /Lesson 8 - Tilt Ball Switch/Magic8-Ball.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 8 - Tilt Ball Switch/Magic8-Ball.fzz -------------------------------------------------------------------------------- /Lesson 8 - Tilt Ball Switch/Magic8-Ball_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 8 - Tilt Ball Switch/Magic8-Ball_bb.png -------------------------------------------------------------------------------- /Lesson 8 - Tilt Ball Switch/Magic8-Ball_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 8 - Tilt Ball Switch/Magic8-Ball_schem.png -------------------------------------------------------------------------------- /Lesson 8 - Tilt Ball Switch/Magic_8-Ball/Magic_8-Ball.ino: -------------------------------------------------------------------------------- 1 | /* For the Lession 7 - Tilt Ball Switch 2 | * Magic-8 ball using an LCD display 3 | * by Ricardo Moreno 4 | * https://github.com/rmorenojr/ElegooTutorial 5 | * 6 | * Inspired by Arduino Video Tutorial-07 Crystal Ball Magic Ball - by Arduino 7 | * https://www.youtube.com/watch?v=kmIy1Y0Jwo8 8 | * 9 | * Arduino LiquidCrystal web page 10 | * https://www.arduino.cc/en/Reference/LiquidCrystal 11 | * https://github.com/codebendercc/arduino-library-files/tree/master/libraries/LiquidCrystal 12 | * 13 | */ 14 | #include 15 | 16 | //Initialize library with LCD screen 17 | //LiquidCrystal(rs, enable, d4, d5, d6, d7) 18 | // or 19 | //LiquidCrystal(rs, rw, enable, d4, d5, d6, d7) 20 | LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); //instantiates the LiquiCrystal Object class to variable lcd 21 | 22 | //Global Constants 23 | const int tiltSensorPin = 6; 24 | //Global Variables 25 | bool currentSwitchState = LOW; //bool is the standard, and preferred type for boolean 26 | bool prevSwitchState = LOW; 27 | int reply; 28 | 29 | void setup(){ 30 | lcd.begin(16, 2); //16 characters and two lines 31 | pinMode(tiltSensorPin, INPUT_PULLUP); //sets the pinmode for the tilt sensor 32 | lcd.print("Ask the"); //prints the line of text 33 | lcd.setCursor(0,1); //moves the cursor to the next line 34 | lcd.print("Magic 8-Ball!"); //not sure if hyphen will work 35 | } 36 | 37 | void loop(){ 38 | currentSwitchState = debounce(prevSwitchState); //get the tilt sensor value HIGH or LOW 39 | 40 | if (currentSwitchState != prevSwitchState) { //looking for a change in the tilt sensor 41 | if (currentSwitchState == LOW) { //tilt sensor has made a connection 42 | lcd.clear(); //clear the screen 43 | reply = random(8); //random select a number from 0-7 44 | lcd.setCursor(0, 0); //move cursor 45 | lcd.print("8-ball says:"); //print the line of text 46 | lcd.setCursor(0, 1); //move the cursor 47 | 48 | switch(reply){ //switch statement jumps to case with a reply value (0-7) 49 | case 0: 50 | lcd.print("Yes"); 51 | break; 52 | case 1: 53 | lcd.print("Most likely"); 54 | break; 55 | case 2: 56 | lcd.print("Certainly"); 57 | break; 58 | case 3: 59 | lcd.print("Outlook good"); 60 | break; 61 | case 4: 62 | lcd.print("Unsure"); 63 | break; 64 | case 5: 65 | lcd.print("Ask again"); 66 | break; 67 | case 6: 68 | lcd.print("Doubtful"); 69 | break; 70 | case 7: 71 | lcd.print("No"); 72 | break; 73 | } 74 | } 75 | else { //Detected that the switch is HIGH or tilted down 76 | lcd.clear(); //clear the screen 77 | lcd.setCursor(0, 0); //move cursor 78 | lcd.print("8-ball says:"); //print the line of text 79 | lcd.setCursor(0, 1); //move the cursor 80 | } 81 | 82 | } 83 | //Save the current state into previous state 84 | prevSwitchState = currentSwitchState; 85 | } 86 | 87 | /* *********************************************************** 88 | * Functions 89 | * *********************************************************** */ 90 | 91 | //Debouncing function 92 | bool debounce(boolean last){ 93 | //Local Variable 94 | bool current = digitalRead(tiltSensorPin); 95 | 96 | if(last != current){ 97 | delay(100); //100 milliseconds 98 | current = digitalRead(tiltSensorPin); 99 | } 100 | return current; 101 | } 102 | 103 | -------------------------------------------------------------------------------- /Lesson 8 - Tilt Ball Switch/README.md: -------------------------------------------------------------------------------- 1 | # ElegooTutorial 2 | 3 | ## Lesson 8 – Tilt Ball Switch and the Magic 8-ball 4 | 5 | [YouTube Video](https://youtu.be/1uXvVbkz45o) 6 | 7 | A beginner's guide to the Most Complete Starter Kit by Elegoo. **Lesson 8 – Tilt Ball Switch** 8 | 9 | Hello everyone, I'm Rick the Tech Enthusiast here with the next Lesson number 8 “Tilt Ball Switch”. This is the next lesson on my Arduino UNO Series covering the Most Complete Starter Kit by Elegoo. I try to follow the tutorial closely, without overburdening the viewer with every detail, but I will point out any changes or corrections as I find them. 10 | 11 | As mentioned before, I purchased this Elegoo starter kit. I’m pronouncing it El-E-Goo, I hope that’s right (I sometimes slip and say El-a-Goo). No, Elegoo isn't sponsoring me. I just thought it would be fun to do a video of each Lesson as I was learning the Arduino environment. 12 | 13 | For this video, we’ll need a few things from your Elegoo Arduino kit. I’ll list the items below. In this lesson we’re going to learn about the tilt sensor or the tilt ball switch is and how to use them in our projects. I step through the Elegoo provided code to explain how it makes this happen. This time we modified the sketch before we run the circuit to correct and update various parts of the code. For bonus sketch, I re-created the Magic 8-ball as shown in Arduino Video Tutorial-07 Crystal Ball Magic Ball - by Arduino. This time we get try the 1602 LCD display available in the kit. Another fun video to make. 14 | 15 | ## Parts you’ll need for the basic tutorial 16 | 17 | * Arduino UNO R3 board 18 | * Tilt Ball Switch 19 | * Two female-to-male jumpers 20 | 21 | ## The Bonus Magic 8-Ball parts 22 | 23 | * Arduino UNO R3 board 24 | * Tilt ball switch 25 | * 1602 LCD panel 26 | * 10K potentiometer 27 | * Two female-to-male jumpers wire 28 | * Various breadboard jumper wires 29 | * Breadboard 30 | 31 | The next lesson will be **Lesson 9 – Servo** 32 | 33 | ## Links 34 | 35 | This lesson’s sketch and associated drawings can be found at [Github](https://github.com/rmorenojr/ElegooTutorial) 36 | 37 | 38 | * SunFounder LCD1602 Module with 3.3V Backlight for Arduino Uno R3 Mega2560 Raspberry Pi 16x2 Character White on Blue Background 39 | 40 | * Cylewet 10Pcs 5V 2 Terminals Passive Electronic Alarm Buzzer Electromagnetic Beeper AC Impedance for Arduino (Pack of 10) CYT1008 41 | 42 | * Elegoo EL-KIT-001 UNO R3 Project Complete Starter Kit with Tutorial for Arduino (63 Items) 43 | * [Elegoo’s web site](https://www.elegoo.com/) - [Complete Starter Kit](https://www.elegoo.com/product/elegoo-uno-r3-project-complete-starter-kit/) 44 | 45 | * [Fritzing Software](http://fritzing.org/download/) 46 | 47 | * [Arduino Language Reference (English)](https://www.arduino.cc/reference/en/) 48 | * [attachinterrupt](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/) 49 | * [Switch Case control](https://www.arduino.cc/reference/en/language/structure/control-structure/switchcase/) 50 | * [Arduino LiquidCrystal web page](https://www.arduino.cc/en/Reference/LiquidCrystal) 51 | * [codebendercc LiquidCrystal](https://github.com/codebendercc/arduino-library-files/tree/master/libraries/LiquidCrystal) 52 | 53 | * [Inspired by Arduino Video Tutorial-07 Crystal Ball Magic Ball](https://www.youtube.com/watch?v=kmIy1Y0Jwo8) - by Arduino 54 | 55 | * Music provided by Free Music Archive, by artist Jahzzar - [Jahzzar_-_04_-_Magic_Mountain](http://freemusicarchive.org/music/Jahzzar/) 56 | 57 | This is the ninth video on a new Arduino tutorial series. If you like the series, be sure to rate and subscribe. 58 | 59 | Thanks for watching 60 | -------------------------------------------------------------------------------- /Lesson 8 - Tilt Ball Switch/myBall_Switch/myBall_Switch.ino: -------------------------------------------------------------------------------- 1 | //www.elegoo.com 2 | //2016.12.08 3 | /*****************************************/ 4 | //Using predefined LED_BUILTIN = 13 5 | const int tiltSensorPin = 2; //the tilt ball switch pin 6 | 7 | void setup() 8 | { 9 | pinMode(LED_BUILTIN, OUTPUT); //initialize the ledPin as an output 10 | pinMode(tiltSensorPin,INPUT_PULLUP); //set the tilt switch input and set to high using pull up resistors 11 | 12 | } 13 | 14 | /******************************************/ 15 | void loop() 16 | { 17 | int digitalVal = digitalRead(tiltSensorPin); //Returns a HIGH or LOW 18 | if(digitalVal) 19 | { 20 | digitalWrite(LED_BUILTIN, LOW); //turns the led off 21 | } 22 | else 23 | { 24 | digitalWrite(LED_BUILTIN, HIGH); //turns the led on 25 | } 26 | } 27 | /**********************************************/ 28 | 29 | -------------------------------------------------------------------------------- /Lesson 9 - Servo/Lesson 9 Servo_RotaryEncoder.fzz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 9 - Servo/Lesson 9 Servo_RotaryEncoder.fzz -------------------------------------------------------------------------------- /Lesson 9 - Servo/Lesson 9 Servo_RotaryEncoder_bb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 9 - Servo/Lesson 9 Servo_RotaryEncoder_bb.png -------------------------------------------------------------------------------- /Lesson 9 - Servo/Lesson 9 Servo_RotaryEncoder_schem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 9 - Servo/Lesson 9 Servo_RotaryEncoder_schem.png -------------------------------------------------------------------------------- /Lesson 9 - Servo/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rmorenojr/ElegooTutorial/3566417be56d1b6859d4f922f738ab6bdc2305f1/Lesson 9 - Servo/README.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ElegooTutorial 2 | Elegoo tutorials 3 | 4 | Ricardo Moreno Jr. 5 | 6 | Modified and Bonus material for The Most Complete Starter Kit for the Arduino Uno by **Elegoo** YouTube Tutorials. 7 | 8 | This Project will be divided into Lesson folders that hold all the various modified sketches, bonus material, schematics, wiring diagrams and any support materials for the Elegoo Arduino UNO Tutorial Series. 9 | 10 | [YoutTube Arduino Video Series](https://www.youtube.com/playlist?list=PLMzVxVmsv2vnCy0GSZjXaMdBQKLbmHOZR) 11 | 12 | -------------------------------------------------------------------------------- /UNLICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=ElegooTutorial 2 | version=1.0.0 3 | author=Ricardo Moreno Jr. 4 | maintainer=Ricardo Moreno Jr. 5 | sentence=Modified and Bonus material for The Most Complete Starter Kit for the Arduino Uno by Elegoo YouTube Tutorials. 6 | paragraph=This directory contains various updated and bonus circuits, schematics, wiring diagrams developed for the Elegoo Arduino Tutorial series. https://www.youtube.com/watch?v=xmRk_wU3lhQ&list=PLMzVxVmsv2vnCy0GSZjXaMdBQKLbmHOZR 7 | category=Tutorial 8 | url=https://github.com/rmorenojr/ElegooTutorial/ 9 | architectures=avr 10 | includes=none 11 | --------------------------------------------------------------------------------