| Arduino Forum ::  Members :: ppsieradzki
 Show Posts Pages: [1]
 1 Using Arduino / Programming Questions / Re: Calculating Percentages yields 0% or 100%- never between on: September 02, 2014, 11:31:26 am vaj4088, thank you! You guys go above and beyond
 2 Using Arduino / Programming Questions / Re: Calculating Percentages yields 0% or 100%- never between on: September 01, 2014, 09:51:49 am @BulldogLowell, your fix worked! Thank you!@westfw, your code didn't exactly work.. it did change to nonzero, but the math was off. I think BulldogLowell's fix is the most accurate. I added in (int) to the whole thing to get a nice round number
 3 Using Arduino / Programming Questions / Calculating Percentages yields 0% or 100%- never between on: August 31, 2014, 09:47:27 pm Hello! I'm trying to calculate the percentage of something in Arduino. More specifically, I have a fan that I'm reading the RPM from. I know it's maximum RPM, so I would like to be able to display both its RPM and its % speed (0%-100%). I have no problem reading the RPM, but for some reason, I can't get the % to calculate! Is there something I'm missing? Full code below:Code://Calculate RPM from fan tachometer:int fanRPM= 0;int maxfanRPM= 1380;float fanRPM_percentage= 0;unsigned long lastmillis= 0;int half_revolutions= 0; //--------------------------------------------------------------------------------------  void RPM_fan()  // this code will be executed every time the interrupt 0 (pin 2) gets low. {  half_revolutions= half_revolutions + 1; }//--------------------------------------------------------------------------------------void setup(){ Serial.begin(9600);  attachInterrupt(0, RPM_fan, FALLING); } //--------------------------------------------------------------------------------------  void loop() {   if (millis() - lastmillis == 1000) //Update every second   {      detachInterrupt(0); //Disable interrupt when calculating     fanRPM= half_revolutions * 30; //Convert frecuency to RPM, note: this works for one interruption per full rotation. For two interrups per full rotation use half_revolutions * 30.     fanRPM_percentage= (fanRPM / maxfanRPM) * 100;     Serial.print("Fan Speed: ");     Serial.print(fanRPM);     Serial.print(" (");     Serial.print(fanRPM_percentage);     Serial.println("%)");     half_revolutions = 0;     fanRPM= 0;     fanRPM_percentage= 0;     lastmillis = millis();     attachInterrupt(0, RPM_fan, FALLING); //Enable interrupt  } } //--------------------------------END OF PROGRAM------------------------------------------Thanks in advance!!
 4 Using Arduino / Sensors / Re: Parallax RFID Read/Write Module 28440 on: May 31, 2013, 06:29:22 pm I'm trying to get this to work with an Arduino Mega 2560. I'm also working with the Blue Fob tags sold by Parallax (https://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/503/Default.aspx?txtSearch=blue+fob) which work on the EM-4100 tech, which I suppose we are referring to as 'legacy'. I cannot for the life of me get a read. In addition, the LED on the RFID reader is always GREEN, not red as I believe it should be, correct? According to Arduino's SoftwareSerial example, though: "Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69" (http://arduino.cc/en/Tutorial/SoftwareSerialExample so I use 10 typically for RX and anything else for TX, but that really shouldn't matter since I only want to read.Can anyone give me any pointers?
 5 Using Arduino / Sensors / Re: Parallax RFID Read/Write Module 28440 on: May 31, 2013, 06:18:43 pm Thank you all for doing all of this work. I'm working on a Mega 2560 and cannot get this to work at all. I tried many examples, including the ones on this page. If it makes any difference, I'm using the "Blue Eye Key Fob Tag" from Parallax that uses the EM-4100 tech.According to Arduino's SofwareSerial example, (http://arduino.cc/en/Tutorial/SoftwareSerialExample) "Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX:  10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69"So I naturally just changed the RX pin to any one of the above. I only want to read tags, not write them, so I suppose TX doesn't really matter, but I hook it up anyway. Still nothing.Can anyone give me any pointers for a Mega 2560?
 6 Using Arduino / LEDs and Multiplexing / Re: General U8glib Question on: January 04, 2013, 09:09:24 pm I actually can't post my entire code because it's too long!
 7 Using Arduino / LEDs and Multiplexing / General U8glib Question on: January 04, 2013, 09:07:34 pm Hello,I'm trying to create a system with a bit of pizazz, making a sort of boot screen. My setup includes (among other things), an IR motion sensor (link) and a display being driven by the U8glib. The IR motion sensor requires a calibration time. Instead of the LCD being blank, I want to do a countdown. But this is unfortunately not in the loop() section, but in the setup() section. Any attempt to do Code:u8g.setFont(u8g_font_fur14);u8g.drawStr( 10, 35, "HAMMOND");in that section just gets ignored by the display. Any ideas on how to do this? I really appreciate your help, and here is my full code if you want to take a look:[EDIT: code in next post because it's too long!](I know it's really long, that's because it includes a LOT of other things, but I tried to keep it as neat and labeled as I could!)