Digital is

Analog is usually a range

// void setup() {
//   // put your setup code here, to run once:
//   pinMode(13,OUTPUT); // Setup the pin 13 = OUTPUT
//   pinMode(2, INPUT); // Setup the pin 2 = INPUT
  
// }

// void loop() {
//   // put your main code here, to run repeatedly:
//   digitalWrite(13, HIGH); // Turn pin 13 on
//   delay(1000); // Do nothing / Stay the same for 1 second/1000ms

//   digitalWrite(13, LOW); // Turn pin 13 on
//   delay(1000); // Do nothing / Stay the same for 1 second/1000ms
// }

// void loop() {
//   // put your main code here, to run repeatedly:
//   // digitalWrite(13, HIGH); // Turn pin 13 on

//   // if button is pressed LED turn on
//   digitalRead(2,)

// }

// // PComp 2023
// // Variables

// int     x = 1;              // integer number // full number value
// float   y = 1.342;          // float number // with decimals for the output you can also decide the decimal count
// char    z = 'a';            // character
// String  w = "hello world";  // sequence of characters (words / phrases)

// void setup() {
//   // put your setup code here, to run once:

//   Serial.begin(9600);       // initialize serial (console) at 9600 bps. // 
// }

// void loop() {
//   // put your main code here, to run repeatedly:

//   Serial.println( w );      // print to console
//   delay(10);                // delay in between for readability
// // }

// // PComp 2023
// // Digital Input - CheckInput

// void setup() {
//   // put your setup code here, to run once:

//   Serial.begin(9600);           // initialize serial (console) at 9600 bps.
//   pinMode(2, INPUT);          // initialize digital pin 2 as an input. (BUTTON)
// }

// void loop() {
//   // put your main code here, to run repeatedly:
  
//   Serial.print( digitalRead(2) );  // print the state of the input pin.
//   delay(10);                           // delay in between reads for stability
// }

// // Pins / Not changing because they are constants

// const int buttonPin = 2; // const means compute once, and it will be same always to save from memory.
// const int ledPin = 13;

// // Variables // State is changing because not constants
// int buttonState = 0;

// void setup(){
//   pinMode(buttonPin ,INPUT); // this is my button
//   pinMode(ledPin, OUTPUT); // this is my output for LED
// }

// void loop(){
  
//   // Check if button is pressed
//   buttonState = digitalRead(buttonPin);

//   // if button is pressed, LED turn on
//   if (digitalRead(buttonPin) == 1){
//     digitalWrite(ledPin, HIGH);
//   } 
//   // if button is not pressed, LED turn off
//   else { 
//       digitalWrite(ledPin, LOW);
//     }
// }

// PComp 2023
// Digital Output - Button

// // constants won't change.
// const int buttonPin = 2;     // Button pin
// const int ledPin = 13;        // LED pin

// // variables will change:
// int buttonState = 1;         // variable for reading the pushbutton state // current state
// void setup() {
//   // put your setup code here, to run once:

//   pinMode(buttonPin, INPUT);       // initialize digital pin 12 (buttonPin) as an input.
//   pinMode(ledPin, OUTPUT);          // initialize digital pin 13 (ledPin) as an output.
// }

// void loop() {
//   // put your main code here, to run repeatedly:

//   // read the state of the pushbutton value:
//   buttonState = digitalRead(buttonPin);

//   // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
//   if (buttonState == HIGH) {
//     // turn LED on:
//     digitalWrite(ledPin, HIGH);
// }
  
//   buttonState = digitalRead(buttonPin);

//   if (buttonState == HIGH){
//     digitalWrite(ledPin, LOW);
//   } 
// }

// ICP Workshop 2020
// Digital Output - Toggle

// // this constant won't change:
// const int  buttonPin = 2;   // the pin that the pushbutton is attached to
// const int ledPin = 13;       // the pin that the LED is attached to

// // Variables will change:
// int buttonState = 1;         // current state of the button
// int lastButtonState = 0;     // previous state of the button

// long time = 0;               // the last time the output pin was toggled
// long debounce = 200;         // the debounce time, increase if the output flickers

// void setup() {
//   // put your setup code here, to run once:

//   pinMode(buttonPin, INPUT);       // initialize digital pin 12 (buttonPin) as an input.
//   pinMode(ledPin, OUTPUT);          // initialize digital pin 13 (ledPin) as an output.
// }

// void loop() {
//   // read the pushbutton input pin:

//   buttonState = digitalRead(buttonPin);

//   if (buttonState == HIGH && millis() - time > debounce) {
//     if (lastButtonState == HIGH) {
//       buttonState = LOW;
//     }
//     else {
//       buttonState = HIGH;
//     }
//     time = millis();
//     digitalWrite(ledPin, buttonState);
//     lastButtonState = buttonState;
//   }
// }

// ICP Workshop 2020
// Digital Output - Timer

// Constants won't change:
const int  buttonPin = 2;   // the pin that the pushbutton is attached to
const int ledPin = 13;       // the pin that the LED is attached to

// Variables will change:
int buttonState = 1;         // current state of the button
int lastButtonState = 0;     // previous state of the button

int brightness = 255;
int fade = 5;
long time = 0;               // the last time the output pin was toggled
long debounce = 200;         // the debounce time, increase if the output flickers

void setup() {
  // put your setup code here, to run once:

  pinMode(buttonPin, INPUT);       // initialize digital pin 12 (buttonPin) as an input.
  pinMode(ledPin, OUTPUT);          // initialize digital pin 13 (ledPin) as an output.
}

void loop() {
  // read the pushbutton input pin:

  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH && millis() - time > debounce) {
    if (lastButtonState == HIGH) {
      buttonState = LOW;
    }
    else {
      buttonState = HIGH;
    }
    time = millis();
    
    digitalWrite(ledPin, buttonState);    // Turn LED ON
    lastButtonState = buttonState;        // Update Button State                          // wait for 3 seconds
    buttonState = LOW;                    // Change Button state to OFF (LOW)
    analogWrite(ledPin, brightness);  
    brightness = brightness - fade;
    
    if (brightness <= 0) {
    brightness = 0;
  }

      // Turn LED 
    
  }
}

1st LAB

void setup() {
  Serial.begin(9600);       // initialize serial communications
}
 
void loop() {
  int analogValue = analogRead(A0); // read the analog input
  Serial.println(analogValue);      // print it
}