Ignore

Im trying to paste my code on to here so i can use the code block section in my lab report.

1
2
3
4
5
6
7
8
9
10
11
12
13
void setup() 
{
  // initialize digital pin 11 as an output.
  pinMode(11, OUTPUT);
}
void loop() 
{
  digitalWrite(11, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);              
  digitalWrite(11, LOW);    // turn the LED off by making the voltage LOW
  delay(50);            

}
1
2
3
4
5
6
7
8
9
10
11
void setup()
 {
  pinMode(13, OUTPUT);
}
void loop() 
{
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);           
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(500);        
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
void setup()
 {
  pinMode(13, OUTPUT);
}
void loop() 
{
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);           
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(500);        
}

const int buttonPin = 2;     
const int ledPin =  13;      
int buttonState = 0;        

void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);
}
void loop()
{

  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH) 
{
    digitalWrite(ledPin, HIGH);
    Serial.println("LED CHANGED");
    delay(250);
 }
  else 
{
    digitalWrite(ledPin, LOW);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void loop() 
{
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH) && (ledPin == HIGH)
{
    // turn LED on:
    digitalWrite(ledPin, LOW);
  }
  else {buttonState == HIGH) && (ledPin == LOW)
{
    // turn LED off:
digitalWrite(ledPin, HIGH);
  }
 }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void loop() 
{
  digitalWrite(ledPin, Low);
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH)
 {
    digitalWrite(ledPin, HIGH);
    Serial.println("LED CHANGED");
    delay(250);
  }
  else 
{
digitalWrite(ledPin, LOW);
  }
 }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

const int buttonPin = 2;   
const int ledPinRED =  13;     
const int ledPinYellow = 12;
const int ledPinGreen=11;
int buttonState = 0;        

void setup() 
{
  pinMode(ledPinRED, OUTPUT);
  pinMode(ledPinYellow, OUTPUT);
  pinMode(ledPinGreen, OUTPUT);
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);
}
void loop()
 {
  digitalWrite(ledPinRED, HIGH);
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH) 
{
    digitalWrite(ledPinRED,LOW);
    digitalWrite(ledPinGreen, HIGH);
    delay(4000);
    digitalWrite(ledPinGreen,LOW);
    digitalWrite(ledPinYellow, HIGH);
    delay(2000);
    digitalWrite(ledPinYellow, LOW);
    digitalWrite(ledPinRED, HIGH);
    Serial.println("LED Cycle Complete");
    delay(250);
  }
  else }
 {
digitalWrite(ledPinRED, HIGH);
 }
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "TimerOne.h"
  int sensorValue;
void setup()
 {
     Serial.begin(9600);
     Timer1.initialize(1000000);
     Timer1.attachInterrupt(callback); 
}
 void callback()
{
     Serial.println(sensorValue); 
 }  

void loop()
{
     sensorValue = analogRead(A0);
     sensorValue = map(sensorValue,0,1023,0,255);
     analogWrite(13,sensorValue);
     int x = analogRead(sensorValue);

}
Topic archived. No new replies allowed.