Lecture notes from 21-2-2018

//
// Operators example for Arduino
// Written by Ted Burke 21-2-2018
//

// TCRT5000 on D7
// Switch on D8

void setup()
{
  // Digital output pins to control motors
  pinMode(4, OUTPUT); // White LED
  pinMode(5, OUTPUT); // Green LED
  pinMode(6, OUTPUT); // Blue LED
}

void loop()
{
  int a, b;

  a = 1;
  b = 1;

  while (1)
  {
    a = digitalRead(8);
    b = digitalRead(7);
    
    digitalWrite(4, HIGH); // white on
    delay(100);
    digitalWrite(4, LOW); // white off
    delay(100);
  }
  
  // Flash blue LED for 5 seconds
  digitalWrite(6, HIGH);
  delay(1000);
  digitalWrite(6, LOW);
}
Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s