Skip to content

Instantly share code, notes, and snippets.

View mjdargen's full-sized avatar

Michael D'Argenio mjdargen

View GitHub Profile
@mjdargen
mjdargen / rc_calc.js
Last active November 16, 2022 06:14
A calculator that computes the best configuration of resistors or capacitors you have to achieve an equivalent value.
/* --------------------------------------------------------------- */
/* r/c calculator scripting */
/* ----------------------------------------------------------------*/
var closest_val; // closest value so far
var closest_diff = 1000000.00; // diff of val and target
var closest = []; // array detailing values of components
var ser_par_config = []; // array detailing serial/parallel
var outputStr = "";
// More API functions here:
// https://github.com/googlecreativelab/teachablemachine-community/tree/master/libraries/image
let model, webcam, labelContainer, maxPredictions;
// Load the image model and setup the webcam
async function init() {
const URL = "https://teachablemachine.withgoogle.com/models/uSXPV8Y2/";
const modelURL = URL + 'model.json';
@mjdargen
mjdargen / steinhardt.ino
Last active April 15, 2021 12:12
Steinhardt-Hart Equation for computing temperature from a thermistor.
float R1 = 10000; // resistance value of the fixed resistor
float RT; // resistance value of thermistor
float T; // final temperature value
int therm_val; // where you will store the value from analogRead()
// get the value
/* INSERT CODE HERE TO RETRIEVE THE ANALOG VALUE & STORE IT IN therm_val */
// this is the math equation for computing the resistance of thermistor
RT = R1 * (1023 - therm_val) / therm_val;
/*
Liquid Crystal
The LCD circuit:
* LCD RS pin to digital pin 7
* LCD Enable pin to digital pin 8
* LCD D4 pin to digital pin 9
* LCD D5 pin to digital pin 10
* LCD D6 pin to digital pin 11
* LCD D7 pin to digital pin 12
// MPU6050 IMU starter code
// include necessary files for MPU6050
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
// declare MPU6050 object
Adafruit_MPU6050 mpu;
// Basic demo for IR remote/receiver
// include IR remote library
#include <IRremote.h>
// define pin and declare object
#define IR_RCVR_PIN 11
IRrecv irrecv(IR_RCVR_PIN);
// servoMove - can use this instead of servo.write
// function to easily move servo at any speed
// end_pos - position you would like to move the servo to
// ms_deg - how many milliseconds per degree (inverse speed)
// * can't move faster than 2 ms per degree
// * typically range from 2 (fast) to 50 (slow)
// Exp: servoMove(0, 2);
void servoMove(Servo _servo, int end_pos, int ms_deg) {
// get current position
/* Activity 00 - Blinky
Turns LED on for one second, then off for one second, repeatedly.
Sends a serial message indicating whether LED is "on" or "off".
Uses onboard LED connected to pin 13.
*/
#define LED_PIN 13 // define LED pin
// put your setup code here, to run once:
# get most recent gmail subject line
import sys
import imaplib
import email
import email.header
EMAIL_ACCOUNT = "......@gmail.com"
ACCOUNT_PW = ""
EMAIL_FOLDER = "INBOX"
/* Activity 01 - Random Blinky
Blinks LED chaotically based on a random number.
Uses onboard LED connected to pin 13.
*/
#define LED_PIN 13 // define LED pin
// put your setup code here, to run once:
void setup() {