Arduino Night: Difference between revisions

From Unallocated Space
Jump to navigation Jump to search
No edit summary
Line 2: Line 2:
Various code snippets used during class - http://pastebin.com/u/uas_arduino
Various code snippets used during class - http://pastebin.com/u/uas_arduino


==Random Code==
==Classes==
* Writing an arbitrary number of bits to pins
1) Here we go again -done
  byte pins[] = {2,3,4,5,6,7};
2) Digital Write
  byte totalPins = 6;
3) Digital Read
 
4) Analog Write
  void setup(){
5) Analog Read
      for(byte a = 0; a < totalPins; a++){
6) Serial
        pinMode(pins[a], OUTPUT);
7) Interrupts
      }
8) ShiftOut In
  }
9) I2C
 
10) SPI
  void writeData(byte data, byte numberOfBits, byte startBit){
11)  
      for(byte a = startBit; a < numberOfBits; a++){
12)  
        if((data >> a) & 0x01){
13)
            digitalWrite(pins[a], HIGH);
        }else{
            digitalWrite(pins[a], LOW);
        }
      }
  }

Revision as of 13:50, 18 June 2016

External code links

Various code snippets used during class - http://pastebin.com/u/uas_arduino

Classes

1) Here we go again -done 2) Digital Write 3) Digital Read 4) Analog Write 5) Analog Read 6) Serial 7) Interrupts 8) ShiftOut In 9) I2C 10) SPI 11) 12) 13)