Skip to content

Instantly share code, notes, and snippets.

void setup()
{
for (int i = 1; i < 9; i++)
{
pinMode(i, OUTPUT);
}
}
void loop()
{
@cbscribe
cbscribe / gist:19e593e5c52df552b7a066861df34d3a
Created November 2, 2020 19:10
Arduino example: LED toggle button
void setup()
{
pinMode(12, OUTPUT);
pinMode(2, INPUT_PULLUP);
}
int button;
int last_button;
int led = LOW;
void loop()
#include <stdio.h>
#include <stdlib.h>
#include <cs50.h>
#include <time.h>
#define DECK_SIZE 52
// strings for pretty printing values
string ranks[] = {"", "A", "2", "3", "4", "5", "6",
"7", "8", "9", "10", "J", "Q", "K"};
@cbscribe
cbscribe / stack.c
Last active November 6, 2020 18:43
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <cs50.h>
bool push(char *item);
char *pop(void);
bool is_empty(void);
bool is_full(void);
@cbscribe
cbscribe / arduino ws2 #3
Created November 10, 2020 17:21
Arduino worksheet 2, question 3
void setup()
{
pinMode(12, OUTPUT);
pinMode(2, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
}
int led = LOW;
int button_right;
int last_button_right;
int A = 7;
int B = 8;
int C = 9;
int D = 10;
int E = 11;
int F = 12;
int G = 13;
void setup()
{
int A = 7;
int B = 8;
int C = 9;
int D = 10;
int E = 11;
int F = 12;
int G = 13;
byte digits[] = {126, 48, 109, 121, 51,
91, 95, 112, 127, 123};
@cbscribe
cbscribe / list1.c
Created November 18, 2020 18:38
In-class example using linked lists
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int value;
struct node *next;
} node;
node *list = NULL;
@cbscribe
cbscribe / random_number.c
Created November 19, 2020 19:47
Pick a random number and display it on the 7-segment display
int A = 7;
int B = 8;
int C = 9;
int D = 10;
int E = 11;
int F = 12;
int G = 13;
byte digits[] = {126, 48, 109, 121, 51,
91, 95, 112, 127, 115};
@cbscribe
cbscribe / gist:64d65a29326ab8979c0a62f89c41cce1
Created November 30, 2020 19:23
LCD custom character example
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte Alien[] = {
B11111,
B10101,
B11111,
B11111,