//https://github.com/SpenceKonde/ATTinyCore //https://www.hackster.io/porrey/easy-serial-on-the-attiny-2676e6 #include int sense_pin = A7; //ATtiny44 PA7 int charge_pin = 9; //ATtiny44 PB1 //note: rx and tx are reversed. (point of view of the board: transmitting (tx) to the computer's rx int rx_pin = 11; //any pin not used //ATtiny44 PB3 int tx_pin = 4; int value2; int value1; int value; int IN2 = 2; //PA2 int IN1 = 3; //PA3 SoftwareSerial Serial (rx_pin, tx_pin); void setup() { Serial.begin(9600); pinMode (sense_pin, INPUT); pinMode (charge_pin, OUTPUT); pinMode (rx_pin, OUTPUT); pinMode (output_pin, OUTPUT); pinMode(IN2, OUTPUT); pinMode(IN1, OUTPUT); digitalWrite (IN1, LOW); } void loop() { digitalWrite(charge_pin, HIGH); delayMicroseconds(20); value1 = analogRead(sense_pin); delayMicroseconds(200); digitalWrite(charge_pin, LOW); delayMicroseconds(20); value2 = 1023 - analogRead(sense_pin); delayMicroseconds(200); value = (value1 + value2) / 2; Serial.println(value); if (value<500 and value>10) { digitalWrite (IN2, HIGH); delay(4000); //inflate for a while digitalWrite (IN2, LOW); //then deflate delay(4000); //delay to make sure all the air is out before the next inflation } }