hi. third time posting this. have gotten help from two people but both sketches
ID: 3678529 • Letter: H
Question
hi. third time posting this. have gotten help from two people but both sketches show errors. this is for an arduino uno board. any help would be appreciated.
Explanation / Answer
float myNumbers[] ={70.11,-42,1.0,-5.3,1465};
float myMaxNum= myNumbers[0];
float myMinNum= myNumbers[0];
void setup()
{
Serial.begin(9600);
}
void loop()
{
for(int i=0;i<5;i++)
{
if(myNumbers[i] > myMaxnum)
myMaxNum= myNumbers[i];
if(myNumbers[i]< myMinNum)
myMinNum = myNumbers[i];
}
Serial.println("enter 0 for finding minimum number and 9 for maximum number");
if(Serial.avalable()>=0)
{
char userInput= Serial.read();
if(userInput =='0')
{
Serial.println("minimum number is:");
Serial.println(myMinNum);
}
else if( userInput == '9')
{
Serial.println("maximum number is:");
Serial.println(myMaxNum);
}
else
{
Serial.println("Unexpected input! Please type a number of 0 or 9 only!");
Serial.println(userInput); //you can drop this statement
userInput= Serial.read();
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.