there is a function that checks if there is "OFF" signal from IR remote control (lets name this function IR_CHECK). if user presses off button then it stores "1" to a temp variables. if user press "ON" button it stores "0" to that temp variable
on my project there are many other functions (displaying graphic efe,showing scrolling text and other) all these functions are calling IR_CHECK function to check if there is "OFF" or "ON" signal. and they works like this:
if (temp==0){ task_0(); task_1(); task_2(); //... //... } if (temp==1){ task_temperature();//show only temperature }
so when user presses OFF button the only fanction that runs is task_temperature. the only problem is that it needs to wait to finish the current task (some of them are spending some seconds)
the code is really complicated and big. user can program it via IR remote control.
each loop takes about 1-3 minutes. I want the add a new feauture now. "night mode" when user presses "off" button on remote control, the cross display need to show only temperature. (this is night mode). i succed to do that with a flag, but the functions are spending a lot of time and it needs to finish one of them and then go to night mode. for example when it scrolling the time, when user presses "off" button it waits to finish this fuction (maybe about 5-10 seconds) and then it goes to night mode.. and this is not what i want from that. i want to turning on night mode in real time
edit.
i found this void(* resetFunc) (void) = 0; //declare reset function @ address 0 ... resetFunc(); //call reset
Hi i have 2 DS18B20 sensors and i want to recieve temperature values from both sensors. (one by one) Each DS18B20 is connected to different pin. (for example pin 10 and pin 11). How could i do that on code please??
here is the code i am using
Code:
#include <OneWire.h>
// OneWire DS18S20, DS18B20, DS1822 Temperature Example // // http://www.pjrc.com/teensy/td_libs_OneWire.html // // The DallasTemperature library can do all this work for you! // http://milesburton.com/Dallas_Temperature_Control_Library
if ( !ds.search(addr)) { Serial.println("No more addresses."); Serial.println(); ds.reset_search(); delay(250); return; }
Serial.print("ROM ="); for( i = 0; i < 8; i++) { Serial.write(' '); Serial.print(addr[i], HEX); }
if (OneWire::crc8(addr, 7) != addr[7]) { Serial.println("CRC is not valid!"); return; } Serial.println();
// the first ROM byte indicates which chip switch (addr[0]) { case 0x10: Serial.println(" Chip = DS18S20"); // or old DS1820 type_s = 1; break; case 0x28: Serial.println(" Chip = DS18B20"); type_s = 0; break; case 0x22: Serial.println(" Chip = DS1822"); type_s = 0; break; default: Serial.println("Device is not a DS18x20 family device."); return; }
ds.reset(); ds.select(addr); ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(1000); // maybe 750ms is enough, maybe not // we might do a ds.depower() here, but the reset will take care of it.
Serial.print(" Data = "); Serial.print(present,HEX); Serial.print(" "); for ( i = 0; i < 9; i++) { // we need 9 bytes data[i] = ds.read(); Serial.print(data[i], HEX); Serial.print(" "); } Serial.print(" CRC="); Serial.print(OneWire::crc8(data, 8), HEX); Serial.println();
// convert the data to actual temperature
unsigned int raw = (data[1] << 8) | data[0]; if (type_s) { raw = raw << 3; // 9 bit resolution default if (data[7] == 0x10) { // count remain gives full 12 bit resolution raw = (raw & 0xFFF0) + 12 - data[6]; } } else { byte cfg = (data[4] & 0x60); if (cfg == 0x00) raw = raw << 3; // 9 bit resolution, 93.75 ms else if (cfg == 0x20) raw = raw << 2; // 10 bit res, 187.5 ms else if (cfg == 0x40) raw = raw << 1; // 11 bit res, 375 ms // default is 12 bit resolution, 750 ms conversion time } celsius = (float)raw / 16.0; fahrenheit = celsius * 1.8 + 32.0; Serial.print(" Temperature = "); Serial.print(celsius); Serial.print(" Celsius, "); Serial.print(fahrenheit); Serial.println(" Fahrenheit"); }
actually i created my own PCB board with PIC32MX795F512 with many components (FRAM,RAM,EEPROM) and i have common pins on some components (CY62148EV30,DS1744W) i am using arduino code so i prefer to not have common names (variables) on both components. It will be easier to program them
Hi all! I am working on led displays and i'm out of RAM. i tried to use EEPROM and i saw that it is really slow... I'm gonna use 512KB SRAM (http://www.alliancememory.com/pdf/AS6C4008.pdf) with arduino.
becouse it needs too many pins i was thinking to use shift registers for Address Inputs.
i succed to make my own code without library(thanks to an old code of some on this forum). i modified so it works on external function when someone need to read if there is IR signal.
this works on SONY remotes
Code:
int getIRKey() { int total_length=10000; int header_length=7000; int check_on_high=3000; int check_on_low=1000; int ir_data[12]; int ir_result[12]; long pulselow;
for (int i=0;i<total_length;i++){//give time to check all pulses. becouse we dont know where the header low bit is delayMicroseconds(1); if (digitalRead(ir_pin)==LOW){ //if you found low signal pulselow=pulseIn(ir_pin,LOW);//then store in pulselow the length of pulse if (pulselow>header_length){ //if this is the header pulse pulselow=0; for (int j=0;j<12;j++){ ir_data[j] = pulseIn(ir_pin, LOW); //Start measuring bits, I only want low pulses } for(int i=0;i<12;i++) { //Parse them if(ir_data[i]>check_on_high) { //is it a 1? ir_result[i] = 1; } else { if(ir_data[i]>check_on_low) {//is it a 0? ir_result[i] = 0; } else { ir_result[i] = 2; //Flag the data as invalid; I don't know what it is! } } } for(int i=0;i<12;i++) { //Pre-check data for errors if(ir_result[i] > 1) { return -1; //Return -1 on invalid data } } int result = 0; int seed = 1; for(int i=0;i<12;i++) { //Convert bits to integer if(ir_result[i] == 1) { result += seed; } seed = seed * 2; } return result; } } } }