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
/* | |
Doorbell | |
Passive Buzzer/Piezoelectric Speaker | |
* Digital output 8 | |
* Other end of speaker connected to GND | |
Pushbutton (for doorbell): | |
* Digital input 2 |
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
// send trigger pulse by setting it high for 10 us | |
digitalWrite(TRIG_PIN, HIGH); | |
delayMicroseconds(10); | |
digitalWrite(TRIG_PIN, LOW); | |
// Call pulseIn function to wait for High pulse | |
// result will be time in microseconds until pulse is detected | |
long duration = pulseIn(ECHO_PIN, HIGH); | |
// Sound travels at 1115 feet per second |
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
# Run this cell only once if you are having issues with your input/output... | |
# window overflowing and scrolling to the left and right horizontally. | |
# This code is a very hacky way of trying to adjust this. | |
# It resizes colab output window so it doesn't overflow | |
from IPython.display import HTML, display | |
def set_css(): | |
display(HTML(''' | |
<style> | |
pre { |
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
# pip install pyautogui | |
import pyautogui | |
# pip install pillow | |
from PIL import ImageGrab | |
import time | |
def click(key): | |
pyautogui.keyDown(key) | |
return |
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
# import the math library for flooring function | |
import math | |
# define a new function that always rounds up if the digit is 5. | |
# call the function by saying: new_round(num, decimals) | |
# where num is the number you want to round and decimals is the | |
# number of digits after decimal point. | |
# Exp: new_round(2.5, 0) -> 2 | |
# Exp: new_round(2.75, 1) -> 2.8 | |
def new_round(num, decimals=0): |
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
/* | |
* Demo Code for 4x4 Membrane Switch Keypad | |
*/ | |
#include <Keypad.h> | |
// initialization of the 4x4 keypad | |
const byte ROWS = 4; // four rows | |
const byte COLS = 4; // four columns | |
// define the two-dimensional array on the buttons of the keypads |
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
# ping router every 5 minutes, reconnect if fails | |
*/5 * * * * /usr/bin/sudo /home/pi/Documents/reconnect_wlan0.sh > /dev/null |
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
/* | |
Create new file called images.h. | |
Copy the Arduino/C code variables to the right of the matrix picture. | |
Paste the code into the images.h file | |
https://github.com/xantorohara/led-matrix-editor | |
http://xantorohara.github.io/led-matrix-editor/ | |
https://xantorohara.github.io/led-matrix-editor/#003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|00007e99997e0000|000000ffff000000|000000ffff000000|00007e99997e0000|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|003c429999423c00|00007e99997e0000|000000ffff000000|000000ffff000000|00007e99997e0000|003c429999423c00|003c429999423c00|00007e99997e0000|000000ffff000000|000000ffff000000|00007e99997e0000 |
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
#define REST 0 | |
#define NOTE_A0 27 | |
#define NOTE_AS0 29 | |
#define NOTE_B0 31 | |
#define NOTE_C1 33 | |
#define NOTE_CS1 35 | |
#define NOTE_D1 37 | |
#define NOTE_DS1 39 | |
#define NOTE_E1 41 | |
#define NOTE_F1 44 |
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
# ask for input | |
number = int(input("Please enter an 8-bit binary number: ")) | |
# extract each bit | |
bit0 = number % 10 | |
bit1 = number % 100 // 10 | |
bit2 = number % 1000 // 100 | |
bit3 = number % 10000 // 1000 | |
bit4 = number % 100000 // 10000 | |
bit5 = number % 1000000 // 100000 |