Skip to content

Instantly share code, notes, and snippets.

@cbscribe
cbscribe / blinking_leds.c
Created March 25, 2021 16:22
Blink a row of 8 leds using a potentiometer
void setup()
{
for (int i=6; i<=13; i++)
{
pinMode(i, OUTPUT);
}
}
int n = 13;
int add = -1;
@cbscribe
cbscribe / button_toggle.c
Created April 5, 2021 16:25
Arduino LED button toggle
int button;
int last_button;
int led_state = LOW;
void setup()
{
pinMode(13, OUTPUT);
pinMode(2, INPUT_PULLUP);
}
@cbscribe
cbscribe / blockchain.py
Created April 9, 2021 18:20
Blockchain example
import hashlib
import json
from time import time
class Blockchain:
def __init__(self):
self.chain = []
self.pending_transactions = []
self.new_block(previous_hash="1234", proof=100)
@cbscribe
cbscribe / analog_meter.c
Last active April 12, 2021 21:33
Arduino NeoPIxel Examples
#include <Adafruit_NeoPixel.h>
# define PIN 2
# define NUM_PIXELS 6
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, PIN);
void setup()
{
pixels.begin();
}
@cbscribe
cbscribe / lcd_example.c
Created April 15, 2021 16:25
Example Arduino + LCD
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
// Set the size of the display
lcd.begin(16, 2);
// Print out some text
lcd.print("This is a really long line.");
@cbscribe
cbscribe / add.html
Last active April 16, 2021 19:06
Flask Todo list app
{% extends "layout.html" %}
{% block body %}
<form action="/add" method="post">
<input type="text" name="task">
<input type="submit">
</form>
{% endblock %}
@cbscribe
cbscribe / bar.c
Created April 19, 2021 21:48
Arduino+LCD Bar Graph Example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
lcd.begin(16, 2);
}
@cbscribe
cbscribe / pacman.c
Created April 20, 2021 03:46
Arduino+LCD Pacman example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte pacman1[] = {
B01110,
B11111,
B11011,
B11111,
B11100,
@cbscribe
cbscribe / find_d.py
Created April 28, 2021 21:22
Find a value for D (RSA algorithm)
# This program finds a value for D in the RSA algorithm
# Given values for A and E
A = int(input("A: "))
E = int(input("E: "))
# Start at E so D will be bigger
n = E
while True:
n += 1
@cbscribe
cbscribe / rsa_sign.py
Last active February 9, 2022 02:20
Python RSA tools
# Run `pip install pycryptodome` to install Crypto library
from Crypto.PublicKey import RSA
from Crypto.Signature import pss
from Crypto.Hash import SHA256
import base64
def sign():
with open("private.key", "r") as file:
data = file.read()
private_key = RSA.import_key(data)