Skip to content

Instantly share code, notes, and snippets.

View futureshocked's full-sized avatar

Peter Dalmaris futureshocked

View GitHub Profile
@futureshocked
futureshocked / main.cpp
Last active August 22, 2024 01:07
09_ESP32 Signal generator (Oscilloscopes for Busy People)
// 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;
@futureshocked
futureshocked / 08_servo_control.ino
Created October 1, 2019 05:14
08. Arduino servo control oscilloscope demo sketch (Oscilloscopes for Busy People)
/* 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.
*
@futureshocked
futureshocked / 07_PWM.ino
Created October 1, 2019 04:53
07. Arduino PWM oscilloscope demo sketch (Oscilloscopes for Busy People)
/* 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.
@futureshocked
futureshocked / 06_distance_sensor.ino
Created October 1, 2019 04:50
06. Ultrasonic distance sensor HC-SR04 demo sketch (Oscilloscopes for Busy People)
/* 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).
*
@futureshocked
futureshocked / 05_button_reaction.ino
Created October 1, 2019 04:27
05. Arduino button oscilloscope demo sketch (Oscilloscopes for Busy People)
/* 05. Arduino button oscilloscope demo sketch
*
* Use this sketch to see a button press as a waveform event in the
* oscilloscope.
*
* Connect CHA of the oscilloscope to the button signal pin.
*
* Connect CHB to the anode of an LED.
*
* Set the scope to 5us time scale and 200mV voltage scale.
@futureshocked
futureshocked / sensor.ino
Created September 4, 2019 03:05
One of Peter's sketches in which he uses JSON to send data to Adafruit IO and receive, parse the response using ArduinoJSON.
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
@futureshocked
futureshocked / 08.40_-_Grove_dice.ino
Created August 1, 2019 22:56
This sketch implements an electronic dice.
/* 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
@futureshocked
futureshocked / 11.40_-_Loud_noise_detector.ino
Last active July 30, 2019 01:16
Grove For Busy People - Project 5 - loud noise detector
/* 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.
@futureshocked
futureshocked / 10.40_-_Motor_control_with_potentiometer.ino
Created July 30, 2019 01:14
Grove - Project 4: Motor control with a potentiometer
/* 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?
@futureshocked
futureshocked / 09.40_-_Environment_monitor.ino
Created July 30, 2019 01:12
Grove - Project 3: Make an environment monitor
/* 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