This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // With this program, you can use the ESP32 as an ultra-low cost signal generator. | |
| // To learn more, see https://techexplorations.com/courses/oscilloscopes/ | |
| #include <Arduino.h> | |
| #include "waveforms.h" | |
| int i = 0; | |
| int sample_delay = 0; | |
| const byte POT_GPIO = 35; // Potentiometer | |
| int t_sample; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 08. Arduino servo control oscilloscope demo sketch | |
| * | |
| * Use this sketch to experiment with the measurement of a PWM waveform | |
| * used to control a servo motor on an oscilloscope. | |
| * | |
| * Connect CH1 of the oscilloscope to pin 9 that controls the servo. | |
| * | |
| * Use a potentiometer to control the duty cycle and therefore the position of the | |
| * servo. | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 07. Arduino PWM oscilloscope demo sketch | |
| * | |
| * Use this sketch to experiment with the measurement of a PWM waveform | |
| * on an oscilloscope. | |
| * | |
| * Connect CHA of the oscilloscope to the anode of the LED. | |
| * | |
| * Use a potentiometer to control the duty cycle. | |
| * | |
| * Set triggering to Auto, and start the experiment. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 06. Ultrasonic distance sensor HC-SR04 demo sketch | |
| * | |
| * This sketch calculates the distance between the HC-SR04 sensor and | |
| * an object directly infront of it. | |
| * | |
| * To see the trigger and echo waveforms with your oscilloscope, | |
| * connect CHA to the trigger and CHB to the echo pins. | |
| * | |
| * Set up edge trigger to CHA, and set it to 1V (or there about). | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void refresh_readings() { | |
| float f_temperature; | |
| float f_humidity; | |
| float f_pressure; | |
| float f_altitude; | |
| digitalWrite(LED_PIN, HIGH); | |
| postCounter++; // New post, increase the post counter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 8.40 - Grove - Project 2: Make an electronic dice | |
| This sketch implements an electronic dice. | |
| When you press the momentary button or touch the touch sensor, the electronic dice | |
| will start to "roll", and then display your lucky number on the LCD. | |
| During the roll, the gadget will produce a tone of changin pitch, to add to the | |
| anticipation, and several random numbers will appear in the LCD. | |
| Components |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 11.40 - Project 5 - Grove loud noise detector | |
| This sketch implements a loud noise detector. It uses a simple soundsensor to pick up | |
| noise. It calculates the volume of the noise, and if it is above a certain threshold, | |
| it switches on an LED and increases the loud noise counter by 1. | |
| The threshold is configurable via a potentiometer. | |
| The sketch displays its operation parameters on an LCD screen. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 10.40 - Grove - Project 4: Motor control with a potentiometer | |
| This sketch copies the position of a potentiometer to the servo motor. | |
| As you turn the knob of the potentiometer, the servo motor moves accordingLy. | |
| *** A challenge for you: *** | |
| Can you make the necessary changes to this sketch and the hardware so that the motor | |
| indicates the current temperature drawn on a sheet of paper? | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 9.40 - Grove - Project 3: Make an environment monitor | |
| This sketch implements an environment monitor. | |
| It measures and calculates the air temperature using the Grove temperature module (thermistor). | |
| It measures the ambient light using a photoresistor. | |
| It displays the calculated temperature and measured light intensity in the Grove LCD. | |
| If the light intensity is below a certain value, it turns on an LED strip via a Grove relay. | |
| *** A challenge for you: *** | |
| Can you adjust the circuit and sketch so that the value below which the LED strip is turned on can |