I am using Attiny 13a microcontroller for measuring the distance using ultrasonic sensor HC-SR04 but it is not working. Even I could not get any values in serial monitor. I am using the same code with nano it is working fine. Please can anybody help me on this.
The following is the code I have used:
const int trigPin =0;
const int echoPin =1;
const int RelayTrig = 2;
int PumpON_distance = 24; // inches t
int PumpOFF_distance = 8; //
void setup() {
Actually MicroController was worked for Blink Project . After I am trying to upload a different sketck for working with utrasonic sensor, I changed some settings like the clock to 9.6 Mhz and enabled micros. after that it started showing above stated error. But my last updated blink Project is working still now. if I try to upload any new project, even blink project its not getting uploaded
Assuming you have selected the correct processor in the IDE and did not destroy the ATtiny in any way, this is very likely where you have to look for a solution.
Now I changed the Micro Controller to ATMega8 . Now my code uploaded successfully but my utlrasonic sensor not working. I used internaI clock speed of 8Mhz .
I am posting code below:
const int trigPin = 11;
const int echoPin = 12;
const int RelayTrig = 2;
int PumpON_distance = 12; // inches
int PumpOFF_distance = 6; //
void setup() {
Serial.begin(9600);
pinMode (RelayTrig, OUTPUT);
pinMode (A4, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
digitalWrite(A4, HIGH); //Light for testing
delay(1000);
digitalWrite(A4, LOW); //Light for testing