Napsal: 07 říj 2015, 21:58
Bez použití break to nemá valný smysl. Vždyť jsem napsal, že ta konstrukce do-while k tvému problému a programu nemá vztah. Asi se musím omluvit za off-topic s tím do-while, pak vznikají takovéto zmatky.
Vše, co potřebujete vědět o elektronice :-)
http://elektrobastlirna.cz/
Kód: Vybrat vše
void loop() {
//hlavni funkce ke ktere se potrebuju vracet
if (teplomer1() >=50) {
Serial.print("nebezi");
getZkouska();
} else {
Serial.print("bezi");
getTest();
}
}
void getTest() {
do {
//ty podminky se vepisuji sem treba
digitalWrite(2,LOW);
//a potom to return vraci zpet do loop
return;
}while(0); //a to while je tedy konec tohoto podprogramu
}
void getZkouska() {
do {
digitalWrite(8,HIGH);
return;
}while(0);
}
Kód: Vybrat vše
do {
return;
}while(0);
Kód: Vybrat vše
void getZkouska();
{
}
Kód: Vybrat vše
void getZkouska();
{
}
Kód: Vybrat vše
void getZkouska();
{
do {
return;
}while(0);
}
Kód: Vybrat vše
void getZkouska()
{
Serial.println("B");
}
void getZkouska2()
{
Serial.println("Y");
do
{
return;
} while(0);
}
void setup()
{
//Initialize serial and wait for port to open:
Serial.begin(9600);
}
void loop()
{
Serial.println("A");
getZkouska();
Serial.println("C");
Serial.println("X");
getZkouska2();
Serial.println("Z");
}
frpr666 píše:Už vidím chybu! Píšeš: void getZkouska();
Při definici se středník za jméno funkce nedává
Kód: Vybrat vše
digitalWrite(2,LOW);
digitalWrite(8,HIGH);
Kód: Vybrat vše
void getZkouska()
{
Serial.println("B");
}
void getZkouska2()
{
Serial.println("Y");
do
{
return;
} while(0);
}
void setup()
{
//Initialize serial and wait for port to open:
Serial.begin(9600);
}
void loop()
{
Serial.println("A");
getZkouska();
Serial.println("C");
Serial.println("X");
getZkouska2();
Serial.println("Z");
}
Kód: Vybrat vše
#include <OneWire.h>
OneWire ds_2(8);
float teplomer2() {
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius_1, fahrenheit_1;
if ( !ds_2.search(addr)) {
Serial.println();
ds_2.reset_search();
delay(250);
}
for( i = 0; i < 8; i++) {
Serial.write(' ');
}
if (OneWire::crc8(addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
}
ds_2.reset();
ds_2.select(addr);
ds_2.write(0x44, 1); // start conversion, with parasite power on at the end
present = ds_2.reset();
ds_2.select(addr);
ds_2.write(0xBE); // Read Scratchpad
Serial.print(" ");
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds_2.read();
Serial.print(" ");
}
Serial.println();
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10) {
raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
}
celsius_1 = (float)raw / 16.0;
fahrenheit_1 = celsius_1 * 1.8 + 32.0;
float stupne_1 = celsius_1;
return stupne_1;
}
void getZkouska()
{
Serial.println("B");
}
void getZkouska2()
{
Serial.println("Y");
do
{
return;
} while(0);
}
void setup()
{
//Initialize serial and wait for port to open:
Serial.begin(9600);
}
void loop()
{
if (teplomer2() <= 25) {
Serial.println("A");
getZkouska();
Serial.println("C");
} else {
Serial.println("X");
getZkouska2();
}
Serial.println("Z");
Serial.println(teplomer2());
delay(10000);
}
Kód: Vybrat vše
do
{
return;
} while(0);
Kód: Vybrat vše
teplomer2_value = teplomer2();
if (teplomer2_value>20)
{
...
if (teplomer2_value>50)
{
...
}
}