Arduino Notes

Arduino:

variable scope

int led = 13; <--- global scope for parameters

! variables are meant for reassignment
! must declare that variables aren't in a specific scope

(RUN)
void setup {
                       pinMode(led, OUTPUT)
                   }


(CONTINUOUS)
void loop { }

array
a way to list information
no limit to numbers, much like an Excel table
!computers always count from 0

int myArray[] <-- square braces for arrays

int myArray[] = {value1(0), value2(1), value3(2)}; !semicolon to terminate

x = myArray[2]; !value3 is position 2 in myArray ^ (because computers count from 0)

int tempArray[5]; !this creates an array with 5 different values that are 'open'

tempArray[3] = analogRead(pot);

byte flicker[ ] = {180, 30, 255, 200, 10, 90, 150, 60];

Arduino = = digital

PWM = Pulse, Width, Modulation ! there are 6 of these pins on the Uno



byte: goes from 0-255 (either increasing or decreasing a pulse of energy)

v v v CODE FOR THE 3 LED ARDUINO DEMO v v v

int ledPin = 9;
int ledPin2 = 10;
int ledPin3 = 11;

byte flicker[] = {40, 60, 80, 100, 120, 140, 160, 180};
byte flicker2[] = {50, 70, 90, 110, 130, 150, 170, 190};//eight values for my flicker
byte flicker3[] = {60, 80, 100, 120, 140, 160, 180, 200};


void setup() {
  pinMode(ledPin, OUTPUT); //this is the LED
  // put your setup code here, to run once:

}

void loop() {
for(int i=0; I<7; i++){
  analogWrite(ledPin, flicker[i]);
  delay(200);
}
for(int j=0; j<7; j++){
  analogWrite(ledPin2, flicker2[j]);
  delay(300);

  for(int k=0; k<7; k++){ //use ++ to restart the series
  analogWrite(ledPin3, flicker3[k]);
  delay(400);





Comments

Popular posts from this blog

Musings on the TNM Project (Week 6 Debrief)

Week 7 Debrief (Perhaps 1 of 2)