Hello,
I'm a student of robotics and I'm doing a project with ESP32-S3 (simulated on Wokwi) and I'm having a SHA-256, this project has two LEDs, an ultrasound sensor, a buzzer and a vibration motor (Wokwi doesn't have a vibration motor so I used a Servo). The problem is with the ultrasound sensor, because it's not sowing the results that it should. I did this code with Arduino and everything worked perfectly, but when I did this with ESP32-S3, this problem came:
SP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
configspi:0x000000b9
SPIWP:0x00
mode:DIO, clock div:1
load:0x3fce3808,len:0x370
load:0x403c9700,len:0x900
load:0x403cc700,len:0x2364
SHA-256 comparison failed:
Calculated: bea01f04c6f0e287a682f128805e3fce115955179100e98d8f412fe7697f8bdc
Expected: 08ea492e448f88de75319ed18ac319444e578d9c6bc7003c5c4807382bf389bd
Attempting to boot anyway...
entry 0x403c98ac
Here's the code that I'm using:
const int trigPin= 14;
const int echoPin= 13;
const int ledPinGreen= 5;
const int ledPinRed= 4;
const int buzzerPin= 6;
const int vibrationPin= 1;
//letters
const int dot= 200;
const int line= 3*dot;
const int pau= dot;
const int nextLetter= 2*dot;
const int restart= 7*dot;
const int f1= 261.63;
const int f2= 440.00;
const long silent= 30000; // silence
void setup(){
Serial.begin(115200);
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
pinMode(ledPinGreen,OUTPUT);
pinMode(ledPinRed,OUTPUT);
pinMode(buzzerPin,OUTPUT);
pinMode(vibrationPin,OUTPUT);
}
void sensor(){
int duration, distance;
digitalWrite (trigPin, HIGH);
delayMicroseconds (10);
digitalWrite (trigPin, LOW);
duration = pulseIn (echoPin, HIGH);
distance = duration * 0.034 / 2;
Serial.print("Sensor: ");
Serial.print(distance);
Serial.print("cm ");
if (distance < 400) {
digitalWrite(vibrationPin, HIGH);
}
else {
digitalWrite (vibrationPin, LOW);
}
int vibration;
vibration= map(distance, 2, 400, 255, 0);
analogWrite(distance, vibration);
Serial.print ("vibration: ");
Serial.print(vibration);
Serial.println();}
void safeM(){
int safe []= {dot, pau, dot, pau, dot, nextLetter, dot, pau,
line, nextLetter, dot, pau, dot, pau, line, pau,
dot, nextLetter, dot, restart};
int fs []= {f1, silent, f1, silent, f1, silent, f1, silent, f1,
silent, f1, silent, f1, silent, f1, silent, f1,
silent, f1, silent};
for (int s=0; s<20; s++){
tone(buzzerPin, fs[s]);
delay(safe[s]);}
noTone(buzzerPin);
}
void dangerM(){
int danger []= {line, pau, dot, pau, dot, nextLetter, dot, pau,
line, nextLetter, line, pau, dot, nextLetter,
line, pau, line, pau, dot, nextLetter, dot,
nextLetter, dot, pau, line, pau, dot, restart};
int fd []= {f2, silent, f2, silent, f2, silent, f2, silent, f2,
silent, f2, silent, f2, silent, f2, silent, f2,
silent, f2, silent, f2, silent, f2, silent, f2,
silent, f2, silent, f2, silent};
for (int d=0; d<28; d++){
tone(buzzerPin, fd[d]);
delay(danger[d]);}
noTone(buzzerPin);
}
void safeL(){
digitalWrite(ledPinGreen,HIGH);}
void dangerL(){
digitalWrite(ledPinRed,HIGH);}
Here you can see the simulation: projecte robòtica copy - Wokwi Arduino and ESP32 Simulator
I hope someone can help me