Paso 3: codificación
El bosquejo puede ser dividido en tres partes principales:
- Control de temperatura;
- Ritmo cardíaco;
- Señal GSM.
const int pinTemp = A1; // pin of temperature sensor on A1const int analogInPin = A0; //pin of light sensor on A0const int pinLed = 3; //pin of Led Socket on D3float Vout = 0.0; //Volt out float Vin = 3.0; ///Volt of Intel = 3V//Temp sectionvoid loop(){ int val = analogRead(pinTemp); // get analog value resistance=(float)(1023-val)*10000/val; // get resistance temperature=1/(log(resistance/10000)/B+1/298.15)-273.15; // calc temperature delay(1000); // delay 1s }//Heart rate sensorvoid setup(){ pinMode(pinLight, INPUT); //set the Sensor on Analog 0 as an INPUT pinMode(pinLed, OUTPUT); //set the LED on Digital 3 as an OUTPUT } void loop() { digitalWrite(pinLed, HIGH); //set the LED as HIGH int sensorValue = analogRead(pinLight); //read value of Sensor Light Vout = (Vin/1024.0 * sensorValue); //convert sensorValue in Volt delay(1000); }//GSM code is work in progress