// Находит площадь прямоугольника
long a = 0;
long b = 0;
long area = 0;
int nextN = 0;
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
Serial.println(" ");
Serial.println("Ready for calculation");
Serial.println("Enter the length + 'a'");
}
void loop() {
if (Serial.available()){
char c = Serial.read();
if (c == 's') {
Serial.println(" ");
Serial.println("Enter the length ");
}
// char c = Serial.read();
if (c >= '0' && c <= '9') {
nextN = nextN * 10;
nextN = nextN + (c - '0');
}
if (c == 'a') {
a = nextN;
Serial.print("a = ");
Serial.println(a);
Serial.println("Enter the width + 'b'");
nextN = 0;
}
if (c == 'b') {
b = nextN;
Serial.print("b = ");
Serial.println(b);
Serial.println("Enter 'e' to get AREA");
nextN = 0;
}
if (c == 'e') {
Serial.println(" ");
Serial.print("The area is ");
area=long(a*b);
Serial.println(area);
Serial.println("Ready for nex calculation");
}
}
delay(5);
}
_________________________________________________________________________
// Вычисляет идельный вес
int growth = 0;
int weight = 0;
int nextN = 0;
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
Serial.println(" ");
Serial.println("Ready for calculation");
Serial.println("Enter Your growth + 'g'");
}
void loop() {
if (Serial.available()){
char c = Serial.read();
if (c >= '0' && c <= '9') {
nextN = nextN * 10;
nextN = nextN + (c - '0');
}
if (c == 'g') {
weight = nextN;
Serial.print("Growth = ");
Serial.println(growth);
Serial.println("Your ideal Weight is ");
weight=growth-100;
Serial.println(weight);
Serial.println("Ready for nex calculation");
nextN = 0;
}
}
delay(5);
}
_________________________________________________________________________
// Находит выражение по формуле
// Проверка a=11 b=7 c=71 d=3 ответ 80
long a = 0;
long b = 0;
long c = 0;
long d = 0;
long s = 0;
int nextN = 0;
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
Serial.println(" ");
Serial.println("Ready for calculation");
Serial.println("Enter a + 'a'");
}
void loop() {
if (Serial.available()){
char x = Serial.read();
if (x >= '0' && x <= '9') {
nextN = nextN * 10;
nextN = nextN + (x - '0');
}
if (x == 'a') {
a = nextN;
Serial.print("a = ");
Serial.println(a);
Serial.println("Enter b + 'b'");
nextN = 0;
}
if (x == 'b') {
b = nextN;
Serial.print("b = ");
Serial.println(b);
Serial.println("Enter c + 'c'");
nextN = 0;
}
if (x == 'c') {
c = nextN;
Serial.print("c = ");
Serial.println(c);
Serial.println("Enter d + 'd'");
nextN = 0;
}
if (x == 'd') {
d = nextN;
Serial.print("d = ");
Serial.println(d);
Serial.println("Enter 's' to get answer");
nextN = 0;
}
if (x == 's') {
Serial.println(" ");
Serial.print("The answer is ");
s=a*b+b*d-(a*b-c)*d;
Serial.println(s);
Serial.println("Ready for nex calculation");
}
}
delay(5);
}
long a = 0;
long b = 0;
long area = 0;
int nextN = 0;
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
Serial.println(" ");
Serial.println("Ready for calculation");
Serial.println("Enter the length + 'a'");
}
void loop() {
if (Serial.available()){
char c = Serial.read();
if (c == 's') {
Serial.println(" ");
Serial.println("Enter the length ");
}
// char c = Serial.read();
if (c >= '0' && c <= '9') {
nextN = nextN * 10;
nextN = nextN + (c - '0');
}
if (c == 'a') {
a = nextN;
Serial.print("a = ");
Serial.println(a);
Serial.println("Enter the width + 'b'");
nextN = 0;
}
if (c == 'b') {
b = nextN;
Serial.print("b = ");
Serial.println(b);
Serial.println("Enter 'e' to get AREA");
nextN = 0;
}
if (c == 'e') {
Serial.println(" ");
Serial.print("The area is ");
area=long(a*b);
Serial.println(area);
Serial.println("Ready for nex calculation");
}
}
delay(5);
}
_________________________________________________________________________
// Вычисляет идельный вес
int growth = 0;
int weight = 0;
int nextN = 0;
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
Serial.println(" ");
Serial.println("Ready for calculation");
Serial.println("Enter Your growth + 'g'");
}
void loop() {
if (Serial.available()){
char c = Serial.read();
if (c >= '0' && c <= '9') {
nextN = nextN * 10;
nextN = nextN + (c - '0');
}
if (c == 'g') {
weight = nextN;
Serial.print("Growth = ");
Serial.println(growth);
Serial.println("Your ideal Weight is ");
weight=growth-100;
Serial.println(weight);
Serial.println("Ready for nex calculation");
nextN = 0;
}
}
delay(5);
}
_________________________________________________________________________
// Находит выражение по формуле
// Проверка a=11 b=7 c=71 d=3 ответ 80
long a = 0;
long b = 0;
long c = 0;
long d = 0;
long s = 0;
int nextN = 0;
// the setup routine runs once when you press reset:
void setup() {
Serial.begin(9600);
Serial.println(" ");
Serial.println("Ready for calculation");
Serial.println("Enter a + 'a'");
}
void loop() {
if (Serial.available()){
char x = Serial.read();
if (x >= '0' && x <= '9') {
nextN = nextN * 10;
nextN = nextN + (x - '0');
}
if (x == 'a') {
a = nextN;
Serial.print("a = ");
Serial.println(a);
Serial.println("Enter b + 'b'");
nextN = 0;
}
if (x == 'b') {
b = nextN;
Serial.print("b = ");
Serial.println(b);
Serial.println("Enter c + 'c'");
nextN = 0;
}
if (x == 'c') {
c = nextN;
Serial.print("c = ");
Serial.println(c);
Serial.println("Enter d + 'd'");
nextN = 0;
}
if (x == 'd') {
d = nextN;
Serial.print("d = ");
Serial.println(d);
Serial.println("Enter 's' to get answer");
nextN = 0;
}
if (x == 's') {
Serial.println(" ");
Serial.print("The answer is ");
s=a*b+b*d-(a*b-c)*d;
Serial.println(s);
Serial.println("Ready for nex calculation");
}
}
delay(5);
}
_________________________________________________________________________________
Комментариев нет:
Отправить комментарий