#include <TinyWireM.h>
#include <Tiny4kOLED.h>
const byte servo0 = 1; // Servo 1 pin PB0
int pt_Val = 0;
int pw = 1000;
void setup() {
pinMode(servo0, OUTPUT);
oled.begin();
// Clear the memory before turning on the display
oled.clear();
// Turn on the display
oled.on();
}
void loop() {
pt_Val = analogRead(A0); // Potentiometer pin PB2
pw = map(pt_Val, 0, 1023, 1000,2000);
digitalWrite(servo0, HIGH); // Set pin high to start pulse
delayMicroseconds(pw); // High pulse angle data
digitalWrite(servo0,LOW); // Set low for the rest of pulse
delayMicroseconds(20000-pw);
oled.clear();
// The characters in the 8x16 font are 8 pixels wide and 16 pixels tall
// 2 lines of 16 characters exactly fills 128x32
oled.setFontX2Smooth(FONT6X8P);
// Position the cusror
// usage: oled.setCursor(X IN PIXELS, Y IN ROWS OF 8 PIXELS STARTING WITH 0);
oled.setCursor(50, 4);
int disp = map(pw, 1000, 2000, 0, 100);
// Write the text to oled RAM (which is not currently being displayed)
// Wrap strings in F() to save RAM!
oled.print(disp);
}