How to Debug in ATtiny 85 TYWu Example
How to Debug in ATtiny 85 TYWu
Example • Hardware – USB to RS 232 Converter
Example • Install Driver – Download the File http: //www. prolific. com. tw/User. Files/files/PL 2303_P rolific_Driver. Installer_v 1_10_0_20140925. zip – Unzip – Install
Example • Connection USB to RS 232 Converter
Example • Pictures
Example • Sketch #include <Software. Serial. h> #define rx. Pin 3 #define tx. Pin 4 Software. Serial my. Serial(rx. Pin, tx. Pin); void setup() { pin. Mode(3, OUTPUT); my. Serial. begin(9600); }
Example void loop() { int v; v = analog. Read(A 1); my. Serial. print("A 1: "); my. Serial. println(v); delay(500); }
Example • Serial Monitor
Example • Serial Monitor
Exercise • Use ATtiny 85 and Serial Monitor to implement Ultrasonic Distance Estimator
Tinker. Cad Debug Mode • Example
Tinker. Cad Debug Mode • Original Sketch : void loop() { if(analog. Read(A 1) > 512) digital. Write(0, HIGH); else digital. Write(0, LOW); }
Tinker. Cad Debug Mode • New Sketch : void loop() { int rv; rv = analog. Read(A 1); if(rv > 512) digital. Write(0, HIGH); else digital. Write(0, LOW); }
Tinker. Cad Debug Mode • Enable Debug Mode
Tinker. Cad Debug Mode • Guide
Tinker. Cad Debug Mode • Add Breakpoint
Tinker. Cad Debug Mode • Start Simulation Stop on this line
Tinker. Cad Debug Mode • Hover the Variable
Tinker. Cad Debug Mode • Resume Execution • Step Over Next Function
Tinker. Cad Serial Monitor • Arduino UNO
Tinker. Cad Serial Monitor • Sketch for Echo #include <Software. Serial. h> void setup() { Serial. begin(9600); } void loop() { if (Serial. available()) Serial. write(Serial. read()); delay(1); }
Tinker. Cad Serial Monitor • Result
Tinker. Cad Serial Monitor • UNO and ATtiny 85
Tinker. Cad Serial Monitor • Sketch of UNO #include <Software. Serial. h> Software. Serial my. Serial(10, 11); // RX, TX void setup() { Serial. begin(9600); my. Serial. begin(2400); } void loop() { if (my. Serial. available()) Serial. write(my. Serial. read()); if (Serial. available()) my. Serial. write(Serial. read()); delay(1); }
Tinker. Cad Serial Monitor • Sketch of ATtiny 85 #include <Software. Serial. h> #define rx. Pin 1 #define tx. Pin 2 Software. Serial my. Serial(rx. Pin, tx. Pin); int sensor. Pin = A 3; int sensor. Val = 0; char incoming. Byte = 0; void setup() { pin. Mode(sensor. Pin, INPUT); my. Serial. begin(2400); }
Tinker. Cad Serial Monitor • Sketch of ATtiny 85 void loop() { if(millis()%1000==0) { sensor. Val = analog. Read(sensor. Pin); my. Serial. print("Input Val: "); my. Serial. println(sensor. Val); } if (my. Serial. available()) { incoming. Byte = my. Serial. read(); analog. Write(0, incoming. Byte); my. Serial. println(incoming. Byte); delay(100); } delay(1); }
Tinker. Cad Serial Monitor • Result
- Slides: 27