My blog for 4929C during spring semester 2023.
Open Circuit vs Short Circuit
Insert Image
Some Stores:
(Our wires, 22 gauge)
Useful website: Draw.io (but probably easier to just draw circuit by hand)
bit: 1 or 0
8 bits = 1 byte
Range of a byte (0-255), so 256 possible choices including zero. Binary can be all zeros or all ones.
binary base 2 decimal base 10 (Insert Image/ Table for Binary vs Decimal)
bool - true or false byte - unsigned (0 - 255) char - signed byte (-127 - 127) word - (0 - ~64k) int - signed word (~ -32k - ~32k) unsigned long - (0 - 4 mil) float - (decimal place) unsigned means: no +/-
rolling over: ex) byte > more than 255
4 bits - nibble 8 bits - byte 16 bits - word 32 bits - long 32 bits - float (decimal place) 64 bits - double long avoid floating point math if we can, hardware doesn’t do division
data type name value ex) byte sensorValue =0;
void setup() { }
Some functions need parameters. Parenthesis signal a function. No parenthesis signal a variable. Can’t write code without variables. Have to define functions and variables BEFORE using them.
rnd = random() gives us a random, # and stores it in rnd void: function isn’t returning anything. map: scales one range to another.
(insert image of conditional function)
unsigned long timestamp = 0; two equal signs > compare
int LEDState = LOW; const long interval = 1000
void setup() { } pinMode(LEDBUILTIN, OUTPUT);
unsignedlongcurrentimestamp= millis();
if currenttimstamp - previoustimestamp > = () { }
if (LEDState == LOW) {
} (LEDState = HIGH); } else {LEDState = LOW;
} previoustimestamp = currenttimestamp
digitalwrite (LEDBUILTIN, LEDState)