<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>نوشته های PORDEL/PROGRAMME</title><link>https://virgool.ir/feed/@m_33124233</link><description></description><language>fa</language><pubDate>2026-11-12 01:17:12</pubDate><image><url>https://files.virgool.ir/upload/users/1320886/avatar/qmGilg.png</url><title>PORDEL/PROGRAMME</title><link>https://virgool.ir/@m_33124233</link></image><item><title>Arduino Sketch for Temperature Sensors using I2C Java</title><link>https://virgool.ir/@m_33124233/arduino-sketch-for-temperature-sensors-using-i2c-java-juvoeqpwztvl</link><description>#include &lt;OneWire.h&gt;#include &lt;DallasTemperature.h&gt;#include &lt;Wire.h&gt;#define SLAVE_ADDRESS 0x40 //Define GPIO pin constantsconst int POOL_PIN = 3;const int SOLAR_PIN = 5;const int OUTSIDE_PIN = 7;//Define the length of our buffer for the I2C interfaceconst int I2C_BUFFER_LEN = 24;  //IMPORTANT MAX is 32!!!//Load OneWire - proprietary dallas semiconductor sensor protocol - no license requiredOneWire poolTemp(POOL_PIN);OneWire solarTemp(SOLAR_PIN);OneWire outsideTemp(OUTSIDE_PIN);//Load Dallas - proprietary dallas sensor protocol utilizing onewire - no license requiredDallasTemperature poolSensor(&amp;poolTemp);DallasTemperature solarSensor(&amp;solarTemp);DallasTemperature outsideSensor(&amp;outsideTemp);//Define I2C bufferchar data[I2C_BUFFER_LEN];String temperatureData;//Define variable for timerlong prevMillis = 0;long interval = 1000;void setup(void) {  //Connect to temperature sensor buses  poolSensor.begin();  solarSensor.begin();  outsideSensor.begin();  //Start the I2C interface  Wire.begin(SLAVE_ADDRESS);  Wire.onRequest(requestEvent);}void loop(void) {  //Monitor time to read temperature sensors once every defined interval  //Don&#39;t read them faster than every 1 second. they can&#39;t respond that fast   unsigned long currMillis = millis();  if (currMillis - prevMillis &gt; interval) {    prevMillis = currMillis;    readTemperatures();  }}void readTemperatures() {  //Read all three temperature sensors  poolSensor.requestTemperatures();  solarSensor.requestTemperatures();  outsideSensor.requestTemperatures();  //Store temperature data in a string   //We pad right to the full length of the buffer to make sure to overwrite old data  //Data is in the format &#34;88.99|78.12|100.00&#34; where &#34;PoolTemp|SolarTemp|OutsideTemp&#34;  temperatureData = padRight(String(poolSensor.getTempFByIndex(0)) + &#34;|&#34; +                              String(solarSensor.getTempFByIndex(0)) + &#34;|&#34; +                              String(outsideSensor.getTempFByIndex(0)), I2C_BUFFER_LEN);}String padRight(String inStr, int inLen) {  while (inStr.length() &lt; inLen)    inStr = inStr + &#34; &#34;;  return inStr;}void requestEvent() {  //sends data over I2C in the format &#34;88.99|78.12|100.00&#34; where &#34;PoolTemp|SolarTemp|OutsideTemp&#34;  temperatureData.toCharArray(data,I2C_BUFFER_LEN);  Wire.write(data);}</description><category>PORDEL/PROGRAMME</category><author>PORDEL/PROGRAMME</author><pubDate>Wed, 10 Nov 2021 19:53:43 +0330</pubDate></item><item><title>Multithreaded LCD Code - multithread.ino (Updated, v1.1)Arduino</title><link>https://virgool.ir/@m_33124233/multithreaded-lcd-code-multithreadino-updated-v11arduino-u7h0gbxwo2ox</link><description>/*Arduino Protothreading Example v1.1by Drew Alden (@ReanimationXP) 1/12/2016- Update: v1.1 - 8/18/17  Arduino 1.6.6+ prototyping changed, small fixes.  (create functions ahead of use, removed foreach and related library).    Note that TimedAction is now out of date. Be sure to read notes about  TimedAction and WProgram.h / Arduino.h errors.*///COMPONENTS/*This code was made using the Sunfounder Arduino starter kit&#39;s blue LCD.It can be found at Amazon.com in a variety of kits.*///THIRD-PARTY LIBRARIES//these must be manually added to your Arduino IDE installation//TimedAction//allows us to set actions to perform on separate timed intervals//http://playground.arduino.cc/Code/TimedAction//http://wiring.uniandes.edu.co/source/trunk/wiring/firmware/libraries/TimedAction#include &lt;TimedAction.h&gt;//NOTE: This library has an issue on newer versions of Arduino. After//      downloading the library you MUST go into the library directory and//      edit TimedAction.h. Within, overwrite WProgram.h with Arduino.h//NATIVE LIBRARIES#include &lt;LiquidCrystal.h&gt;    /*      LiquidCrystal Library - Hello World         Demonstrates the use a 16x2 LCD display.  The LiquidCrystal     library works with all LCD displays that are compatible with the     Hitachi HD44780 driver. There are many of them out there, and you     can usually tell them by the 16-pin interface.     One example circuit:     * LCD RS pin to digital pin 12.     * LCD Enable/E/EN pin to digital pin 11     * LCD D4 pin to digital pin 5     * LCD D5 pin to digital pin 4     * LCD D6 pin to digital pin 3     * LCD D7 pin to digital pin 2     * LCD R/W pin to ground     * LCD VSS pin to ground     * LCD VCC/VDD pin to 5V     * 10K resistor:     * ends to +5V and ground     * wiper (middle) to LCD VO pin (pin 3)     *Backlit Displays:     * LCD K pin to ground (if present)     * LCD A pin to 220ohm (red red black black (brown)) resistor, then       resistor to pin 9         This example code is in the public domain.         http://www.arduino.cc/en/Tutorial/LiquidCrystal     *///GLOBALSint backlightPin = 9;   // used for backlight fadingint timerCounter = 0;   // incrementing counter. will crash eventually.int stringNo = 0;       //which text string to show//                   &#34;16 CHARACTER MAX&#34;char* stringArray[]={&#34;Check it out... &#34;,                     &#34;I have 3 threads&#34;,                     &#34;going at once...&#34;,                     &#34;Cool, huh?! :D  &#34;};                     //INIT// This should probably be done inside setup(), but whatever.// initialize the LCD library with the numbers of the interface pinsLiquidCrystal lcd(12, 11, 5, 4, 3, 2);//FUNCTIONS//this is our first task, print an incrementing number to the LCDvoid incrementNumber(){   // set the cursor to column 0, line 1  // (note: line 1 is the second row, since counting begins with 0):  lcd.setCursor(0, 1);  // add one to the counter, then display it.  timerCounter = timerCounter + 1;    lcd.print(timerCounter);}//our second task, fires every few seconds and rotates text stringsvoid changeText(){    // Print a message to the LCD.  lcd.setCursor(0, 0);  lcd.print(stringArray[stringNo]);  //nasty hack to get number of Array elements  if (stringNo &gt;= sizeof(stringArray)/sizeof(char *)){      stringNo = 0;    changeText();  }  else{    stringNo = stringNo + 1;    }}//Create a couple timers that will fire repeatedly every x ms//edit: these lines used to be in front of incrementNumber and changeText//      functions. this didn&#39;t work because the functions weren&#39;t defined yet!TimedAction numberThread = TimedAction(700,incrementNumber);TimedAction textThread = TimedAction(3000,changeText);// where&#39;s our third task? well, it&#39;s the main loop itself :) the task// which repeats most often should be used as the loop. other// tasks are able to &#34;interrupt&#34; the fastest repeating task.void setup() {  //define the LCD&#39;s number of columns and rows:  lcd.begin(16, 2);  //fire changeText once to paint the initial string [0]  changeText();}void loop() {    //check on our threads. based on how long the system has been  //running, do they need to fire and do work? if so, do it!  numberThread.check();  textThread.check();    //third task, fade in backlight from min to max brightness  //in increments of 5 points:  digitalWrite(13, HIGH);  for (int fadeValue = 0 ; fadeValue &lt;= 255; fadeValue += 10) {        //wait a second, why am i checking on the threads here? because    //this is a for loop. you must check on your threads during ANY    //loops that occur, including the main one!    numberThread.check();    textThread.check();        //sets the value (range from 0 to 255):    analogWrite(backlightPin, fadeValue);        // wait for 20 milliseconds to see the dimming effect    // keep delays on the main loop SHORT. these WILL prevent    // other threads from firing on time.    delay(20);  }  //fade out from max to min in increments of 5 points:  digitalWrite(13, LOW);  for (int fadeValue = 255 ; fadeValue &gt;= 0; fadeValue -= 10) {        //check on our threads again    numberThread.check();    textThread.check();        //sets the value (range from 0 to 255):    analogWrite(backlightPin, fadeValue);        //wait for 20 milliseconds to see the dimming effect    delay(20);  }    /*      For some scrolling message fun in the future...    lcd.setCursor(15,0);  // set the cursor to column 15, line 0    for (int positionCounter1 = 0; positionCounter1 &lt; 26; positionCounter1++)    {      lcd.scrollDisplayLeft();      //Scrolls the contents of the display one space to the left.      lcd.print(array1[positionCounter1]);      // Print a message to the LCD.      delay(tim);  //wait for 250 microseconds    }    lcd.clear();      //Clears the LCD screen and positions the cursor in the upper-left corner.        lcd.setCursor(15,1);  // set the cursor to column 15, line 1    for (int positionCounter = 0; positionCounter &lt; 26; positionCounter++){      lcd.scrollDisplayLeft();      //Scrolls the contents of the display one space to the left.      lcd.print(array2[positionCounter]);  // Print a message to the LCD.      delay(tim);  //wait for 250 microseconds    }    lcd.clear();    //Clears the LCD screen and positions the cursor in the upper-left corner.  */    }</description><category>PORDEL/PROGRAMME</category><author>PORDEL/PROGRAMME</author><pubDate>Wed, 10 Nov 2021 19:53:19 +0330</pubDate></item><item><title>Simple Programmable Robotic Arm © GPL3+</title><link>https://virgool.ir/@m_33124233/simple-programmable-robotic-arm-©-gpl3-imoeqhttowsh</link><description>//Code written by Ryan Chan; it is pretty inefficient, but gets the job done, I challenge you to make it more efficient!//*IMPORTANT CHANGES IN VERSION 2: LEDs 4 and 5 have been moved to pins 7 and 8 respectively; Buttons 1 and 2 have been moved to pins 12 and 13 respectively. This is to make wiring easier.#include &lt;Servo.h&gt;Servo servo1; //ServosServo servo2;Servo servo3;const int LED1 = 2; //LEDsconst int LED2 = 3;const int LED3 = 4;const int LED4 = 7;const int LED5 = 8;const int button1 = 12; //Buttonsconst int button2 = 13;int button1Presses = 0; //Button valuesboolean button2Pressed = false;const int pot1 = A0; //Potentimetersconst int pot2 = A1; const int pot3 = A2;int pot1Val; //Potentimeter valuesint pot2Val;int pot3Val;int pot1Angle;int pot2Angle;int pot3Angle;int servo1PosSaves[] = {1,1,1,1,1}; //position savesint servo2PosSaves[] = {1,1,1,1,1};int servo3PosSaves[] = {1,1,1,1,1};void setup() {  servo1.attach(5); // Set up everything and will run once; attach servos and define the pin modes  servo2.attach(6);  servo3.attach(9);    pinMode(LED1, OUTPUT);  pinMode(LED2, OUTPUT);  pinMode(LED3, OUTPUT);  pinMode(LED4, OUTPUT);  pinMode(LED5, OUTPUT);  pinMode(button1, INPUT);  pinMode(button2, INPUT);  Serial.begin(9600);}void loop() {  // put your main code here, to run repeatedly:   pot1Val = analogRead(pot1); // This will read the values from the potentimeters and store it...  pot1Angle = map(pot1Val, 0, 1023, 0, 179); // ... and this will map the values from the potentiometers to values the servos can use and store it for later use  pot2Val = analogRead(pot2);   pot2Angle = map(pot2Val, 0, 1023, 0, 179);  pot3Val = analogRead(pot3);  pot3Angle = map(pot3Val, 0, 1023, 0, 179);    servo1.write(pot1Angle); // These will make the servos move to the mapped angles  servo2.write(pot2Angle);  servo3.write(pot3Angle);    if(digitalRead(button1) == HIGH){ // This will check how many times button1 is pressed and save the positions to an array depending on how many times it is pressed; switch/case works like a if statement    button1Presses++;    switch(button1Presses){      case 1:        servo1PosSaves[0] = pot1Angle;        servo2PosSaves[0] = pot2Angle;        servo3PosSaves[0] = pot3Angle;        digitalWrite(LED1, HIGH);        Serial.println(&#34;Pos 1 Saved&#34;);        break;      case 2:         servo1PosSaves[1] = pot1Angle;         servo2PosSaves[1] = pot2Angle;         servo3PosSaves[1] = pot3Angle;         digitalWrite(LED2, HIGH);         Serial.println(&#34;Pos 2 Saved&#34;);         break;      case 3:         servo1PosSaves[2] = pot1Angle;         servo2PosSaves[2] = pot2Angle;         servo3PosSaves[2] = pot3Angle;         digitalWrite(LED3, HIGH);         Serial.println(&#34;Pos 3 Saved&#34;);         break;       case 4:         servo1PosSaves[3] = pot1Angle;         servo2PosSaves[3] = pot2Angle;         servo3PosSaves[3] = pot3Angle;         digitalWrite(LED4, HIGH);         Serial.println(&#34;Pos 4 Saved&#34;);         break;       case 5:         servo1PosSaves[4] = pot1Angle;         servo2PosSaves[4] = pot2Angle;         servo3PosSaves[4] = pot3Angle;         digitalWrite(LED5, HIGH);         Serial.println(&#34;Pos 5 Saved&#34;);         break;    }  }  if(digitalRead(button2) == HIGH){ // Pretty self-explnatory here    button2Pressed = true;     }    if(button2Pressed){ // if the boolean button2Press is true, then the servos will run though all their saved positions    for(int i = 0; i &lt; 5; i++){        servo1.write(servo1PosSaves[i]);        servo2.write(servo2PosSaves[i]);        servo3.write(servo3PosSaves[i]);        Serial.println(&#34; potentimeter Angles: &#34;);        Serial.println(servo1PosSaves[i]);        Serial.println(servo2PosSaves[i]);        Serial.println(servo3PosSaves[i]);        delay(1050);      }  }  delay(300);}</description><category>PORDEL/PROGRAMME</category><author>PORDEL/PROGRAMME</author><pubDate>Wed, 10 Nov 2021 19:51:39 +0330</pubDate></item></channel></rss>