uni

Thing1's amazing uni repo
Log | Files | Refs

31.10.25.md (1493B)


      1 31/10/25
      2 ========
      3 
      4 Clocks
      5 ------
      6 
      7 - `void delay(int ms)` will stop the program for ms number of ms
      8 - `void delayMicroseconds(int us)` will stop the program for us number of us
      9 - `long millis()` number of ms since the system powered on
     10 - `long micros()` number of us since the system powered on
     11 
     12 Digital I/O
     13 -----------
     14 
     15 - `INPUT` is an input
     16 - `OUTPUT` is an output
     17 - `INPUT_PULLUP` is an inverted input
     18 
     19 - `void pinMode(int pin, int mode)` sets a pin to a mode
     20 - `void digitalWrite(int pin, int state)` sets an output pin to a given state
     21     - the states are `HIGH` (5v) and `LOW` (0v)
     22 
     23 - pins shouldn't draw or sink more than 40mA
     24 - 300mA is the max current draw for the whole board
     25 
     26 - the builtin LED has a constant pin number, `LED_BUILTIN`
     27 
     28 - `bool digitalRead(int pin)` reads a pins value
     29     - `HIGH` is anything greater than 3v
     30     - `LOW` is anything lower than 2v
     31     - anything between 3v and 2v will result in undefined behaviour
     32 
     33 Analog I/O
     34 ----------
     35 
     36 - no real analog output, uses PWM and quickly switches to emulate
     37     - the frequency is about 1KHZ
     38 
     39 - `analogWrite(int pin, byte value)` will set the pin to the value, only works on analog pins
     40     - writing to a non analog pin will cause an on/off state
     41     - value is an 8 bit value
     42 
     43 - `int analogRead(int pin)` will give you a value from the ADC
     44     - input is handled by a 10 bit ADC, so the output can be between 0 and 1024 in software
     45     - the pins have the names `A0`, `A1`, `A2`, ...
     46 
     47 Interrupts
     48 ----------
     49 
     50 - RTFM
     51