ATtiny45 Software serial





Please,Click Google Adsense for support this blog.


ref : arduino:SoftwareSerial

software serial ports with speeds 1200,2400 and 4800 bps.

Code:
#include <SoftwareSerial.h>
#define rxPin 1
#define txPin 2
const int analogInPin = 3;  // Analog input pin that the potentiometer is attached to
int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)
SoftwareSerial serial(rxPin, txPin);
void setup()  {
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  serial.begin(4800);
  serial.println("ATtiny45 Software serial");
}
void loop() {
  sensorValue = analogRead(analogInPin);          
  outputValue = map(sensorValue, 0, 1023, 0, 255);          
  serial.print("sensor = " );                    
  serial.print(sensorValue);    
  serial.print("\t output = ");    
  serial.println(outputValue);
  delay(100);  
}