/*
Analog Write: (AKA PWM)
*/

#include <SoftwareSerial.h>
#define SERIAL_TX PB3
#define SERIAL_RX PB0
#define PB1_ADC PB1


SoftwareSerial mySerial(SERIAL_RX, SERIAL_TX);

void setup() {
    mySerial.begin(9600);

    //P0, P1, and P4 are capable of hardware PWM (analogWrite).
    pinMode(PB1, OUTPUT); //0 is P0, 1 is P1, 4 is P4 - unlike the analog inputs, 
                        //for analog (PWM) outputs the pin number matches the port number.
}

void loop() {
    analogWrite(PB1,255); //Turn the pin on full (100%)
    mySerial.print("Sensor Value 100%: ");
    mySerial.print(PB1);
    mySerial.println();
    delay(100);
    analogWrite(PB1,128); //Turn the pin on half (50%)
    mySerial.print("Sensor Value 50%: ");
    mySerial.print(PB1);
    mySerial.println();
    delay(100);
    analogWrite(PB1,0);   //Turn the pin off (0%)
    mySerial.print("Sensor Value 0%: ");
    mySerial.print(PB1);
    mySerial.println();
    delay(100);
}
ATTINY8520PU
D0D1D2D3D4D5D6D7GNDLOGIC