วันอังคารที่ 4 เมษายน พ.ศ. 2560

arduino knowledge technic 2





BitsUnsigned
value
Two's
complement
value
0113 3 
0102 2 
0011 1 
0000 0 
1117 −1 
1106 −2 
1015 −3 
1004 −4 
Eight-bit two's-complement integers
BitsUnsigned
value
Two's
complement
value
0111 1111127 127 
0111 1110126 126 
0000 00102 2 
0000 00011 1 
0000 00000 0 
1111 1111255 −1 
1111 1110254 −2 
1000 0010130 −126 
1000 0001129 −127 
1000 0000128 −128 

/*--------------------------------
จาก math.h   https://www.arduino.cc/en/Math/H
double log (double __x) // natural logarithm of x
 double log10 (double __x) // logarithm of x to base 10.
/*-----------------------------------------------
  lcd.print("TEMP " + (String)(int)Temp_start + "," + (String)(int)Temp_cut );
/*-------------------------------
By-pass and de-coupling capacitors
are commonly used to control the voltage on the VCC pin,
- using a larger capacitor to provide additional power in the event of a short power supply glitch
- and a smaller capacitor to filter out high-frequency ripple.

/*--------------------------------

credit: https://forum.arduino.cc/index.php?topic=372547.0


The first thing to do is ensure you have your relay module connected properly and adequately powered. This example shows how to make use of the optic isolation feature.

INSTRUCTIONS:
  • Remove blue jumper
  • Connect JD-VCC and GND from the Relay Module to a Separate 5VDC Supply (1Amp or greater)
  • Connect VCC from the Relay Module to 5V on your Arduino
  • Connect required control signals as shown
  • Note: DO NOT connect GND from the Relay Module to your Arduino

/*------------------------------------

set bit ตามตำแหน่งที่ต้องการ

Use the bitwise or and and operators. To set a bit:
เซต bit=1 ที่ตำแหน่ง pos
my_byte = my_byte | (1 << pos);
To un-set a bit:
เซต bit=0 ที่ตำแหน่ง pos
my_byte = my_byte & ~(1 << pos);
credit http://stackoverflow.com/questions/4674006/set-specific-bit-in-byte
/*-----------------------

difference between ESP.reset() and ESP.restart()?

What´s the difference between ESP.reset() and ESP.restart()?

Both work, but sometimes the ESP does not start again. 
Answer:
ESP.reset() is a hard reset and can leave some of the registers in the old state which can lead to problems, its more or less like the reset button on the PC.
ESP.restart() tells the SDK to reboot, so its a more clean reboot, use this one if possible.
the boot mode:(1,7) problem is known and only happens at the first restart after serial flashing.
if you do one manual reboot by power or RST pin all will work more info see: #1017

/*-----------------------------------------------

Wrote a test for floats to check for special values. NAN and INFINITY and isnan(), isinf() and isfinite() are defined in math.h.
int testFloat(float f)
{
 if (f == 1/0L)     Serial.println("NaN divide by 0L");
 if (f == 1/0UL)    Serial.println("NaN divide by 0UL");
 if (f == NAN)      Serial.println("NaN");
 if (f == INFINITY) Serial.println("INFINITY");
 if (-f == INFINITY)Serial.println("-INFINITY");
 if (isnan(f))      Serial.println("isnan");
 if (isinf(f))      Serial.println("isinf");
 if (isfinite(f))   Serial.println("isfinite = OK");
 return 0;
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น