Transaction: b668b02603ce6c43205412e347d372c0fe2f30c0

Included in block 23,098,971 at 2018/06/07 00:19:03 (UTC).

Transaction overview

Loading...
Transaction info
transaction_id b668b02603ce6c43205412e347d372c0fe2f30c0
ref_block_num 30,282
block_num23,098,971
ref_block_prefix 205,062,969
expiration2018/06/07T00:29:00
transaction_num 57
extensions[]
signatures 1f2bee8742ab2e3f7e23a546c3b3bba0bc35852ae535ab450124622ce83e5424954fd94f214053315e18a89e728b374c72603de5274ea362df3c4e579330236c7d
operations
comment
"parent_author":"",<br>"parent_permlink":"utopian-io",<br>"author":"electronicsworld",<br>"permlink":"blinkit-v2-4-arduino-integration-or-chose-your-effect",<br>"title":"Blinkit v2.4: Arduino integration | Chose your effect !",<br>"body":"# Blinkit v2.4: Arduino integration | Chose your effect !\n\n&nbsp;\n \n![ (https:\/\/i.imgur.com\/QVv0mJw.png)\n\n&nbsp;\n\nAfter having tested out many times and used Blinkit with Arduino a lot,<br> we started to feel we needed to expand and give to users more choices (eventhough users can find it funny to only blink a led or change the speed and the number of blinks). This is why we decided to implement some effects to be assigned for each notification to let Blinkit become even more an interactive and funny platform to receive Steem related notifications.\n\n&nbsp;\n\n### Arduino standby light breathing and light effects on notifications\n\n&nbsp;\n\nAfter several testing of our last release of the RGB led mode with the light effect during booting of Arduino we have pointed out that,<br> having only a booting light pattern during Arduino start-up phase is surely nice but will not give the right spirit to it as would do a standby \"breathing like effect\". More over we wanted to make it more interactive,<br> funny and nice looking. This is why we also implemented new light effects to be assigned for each notification. Now the effects that can be chosen are: Normal Blink,<br> Fading,<br> Rainbow,<br> Ice and Fire (more to come soon...).\n\n&nbsp;\n\n### What is Blinkit?\nBlinkit is a notification software that can be used to give to regular and widely available devices a Steem purpose.\n\n![ (https:\/\/i.imgur.com\/q4X6I8B.png)\n\n&nbsp;\n\n#### Supported devices:\n* USB Sticks (status light)\n* Philips HUE lamps\n* Sonoff devices\n* Arduino Boards or compatible (Genuino,<br> etc...)\n* Camera status LED blink\n* Take photos on upvote\/post\/follow\n* Logitech RGB\/Backlight Keyboards (new)\n\n\n\n\nBlinkit can look for new Steem account Upvotes and Followers,<br> and it can notify on new Posts made by a user.\n\nMore devices will be added in the near future.\n\nBlinkit is free and open source,<br> and can be downloaded from the Blinkit Github page:\nhttps:\/\/github.com\/techtek\/Blinkit\n\nFor more information about the new version of Blinkit please visit the following [link (https:\/\/utopian.io\/utopian-io\/@techtek\/introducing-blinkit-v2-a-new-user-friendly-interface-to-blink-usb-sticks-and-other-devices-on-steem-related-actions)\n\n&nbsp;\n\n![ (https:\/\/i.imgur.com\/oFeTmS9.gif)\n\n&nbsp;\n\n#### COMPATIBILITY\nCurrent release has been tested only on an Arduino UNO board. Other boards like Mega and Nano should be supported (for Nano different PWM pins should be selected,<br> for Mega nothing to change) but have not been tested yet. Users interested in using this new feature with other boards could submit a test contribution and let us know the result of their test.\n\n&nbsp;\n \n### New Coded Features:\n\n- Light fading pattern (breathing) during Arduino standby period (while no notifications or no changes in settings) \n- New light effects for incoming notifications (fade,<br> ice,<br> fire,<br> rainbow)\n\n---\n\n#### With this release our main concerns were:\n\n- How to let users using single leds and\/or RGB led have some interactive and more funny effects to chose instead of the standard blinking ? \n- How to make sure that connections are well established always?\n- How to make sure that wiring had been made correctly ?\n- How to give some liveliness to the Blinkit related Arduino boards notifiying users that the board is ready to accept new incoming triggers and\/or is waiting for new triggers ??\n\nAfter some brainstorming with @techtek we decided to let that custom made booting light pattern for Blinkit become a \"BREATHING\" effect which will fade the RGB led between the main colours of Blinkit's style: Violet and White. This pattern will be triggered and gets repeated forever whenever the board is in standby (no notifications and no changes in settings). Whenever there is a change (so serial is being received) this pattern stops (it stop breathing !!) and process the info received. Then if nothing is there for few seconds it goes back to breathing waiting for new incoming data.\n\nCencerning the effects,<br> now users can chose from the Blinkit interface which effect to be assigned for each notification.\n\nIn 3x Single led mode the effects available for now are: Normal Blink,<br> Fading.\n\nIn RGB led mode the available effect are: Normal Blink,<br> Fading,<br> Rainbow,<br> Ice,<br> Fire\n\nMore effects to be added soon and more features...\n\nHereafter i will explain the whole process behind the coding and will explain how the code works to let it work as desired. \n\n\n&nbsp;\n\n![ (https:\/\/i.imgur.com\/wJq3gcS.png)\n\n&nbsp;\n\n### How is it implemented?\n\nNew parts have been added to the code with a new approach in handling part of the data. A new section (a new function) in the code has been added which is the breath() function that will be responsible to do the breathing while the board is in standby.\n\nThe main code structure and interaction is still divided in 6 main parts:\n\n- Declare\/set the variables,<br> the arrays etc \n- Initializing the setups (Serial Comunication and Output pins) \n- Receive serial data to be processed\n- Receive serial data and split it in tokens declaring the functions that will handle such data\n- Read splitted data and based on some marker store them in the right setting array\n- Wait for triggers (upvote,<br> follower,<br> post) over serial and activate the led with one of the chosen effects\n\n\nHereafter i will show and explain only the parts of the code where changements have been made.\n\n#### 1) Declare\/set the variables,<br> the arrays etc...\n\n\n\n```\nchar buffer[22 ;\n\nint RedPIN = 3; \/\/pin for led 1 (single colour led) or pin for the Red led in the RGB led\nint GreenPIN = 5; \/\/pin for led 2 (single colour led) or pin for the Green led in the RGB led\nint BluePIN = 6 ; \/\/pin for led 3 (single colour led) or pin for the Blue led in the RGB led\n\/\/above pins must be DIGITAL PWM PINS (in Arduino Uno,<br> PIN 3,<br> 5,<br> 6,<br> 9,<br> 10,<br> 11 are PWM) in order to obtain the colours shades with the RGB led\nint y=0;\nint transferdata[3 ; \/\/array to be used to store the incoming settings and transfer them to the right setting array\nint ledmode[2 ; \/\/this array will store the information regarding the ledmode (mode 1 for 3x single colour leds and mode 2 for 1x RGB led )\nint blinkdelay[3 ; \/\/this array will store the information to be used for the blink speed (in this case it is a delay between blinks)\nint Nofblinks[3 ; \/\/this array will store the information to be used for the number of triggers\/blinks to do (number of repeated triggers)\nint BRIGHTU[3 ; \/\/ This array will store the information regarding the colour of the RGB led for an incoming upvote trigger (3 values for the colour)\nint BRIGHTF[3 ;\/\/ This array will store the information regarding the colour of the RGB led for an incoming follower trigger (3 values for the colour)\nint BRIGHTP[3 ; \/\/ This array will store the information regarding the colour of the RGB led for an incoming post trigger (3 values for the colour)\nint EFFECT[3 ; \/\/ This array will store the information regarding the effect chosen for each led\/notification (1 for normal Blink,<br> 2 for Fading,<br> 3 for rainbow,<br> 4 for ice,<br> 5 for fire)\nunsigned long StartTime; \/\/will be used to calculate timing for fading effect\nunsigned long CurrentTime; \/\/will be used to calculate timing for fading effect\n\n```\n\nAs we can see we have introduced a new array,<br> named EFFECT[ ,<br> which will store the information regarding the effect chosen for each led\/notification (1 for Normal Blink,<br> 2 for Fading,<br> 3 for rainbow,<br> 4 for ice,<br> 5 for fire). New variables have been added as StartTime and CurrentTime which for now will only be used to calculate time and period for the fading effect but will be used even more in next planned updates.\n\n\n#### 3) Receive serial data to be processed\n\n```\nvoid loop() \/\/collecting the incoming data and filling the buffer with it\n StartTime = millis(); \/\/ updating time\n if (Serial.available() > 0) \/\/if there is any incoming serial data of any sort (any setting or any notification)\n int index=0;\n delay(100); \/\/ let the buffer fill up\n int numChar = Serial.available(); \n if (numChar>22) \n numChar=22;\n \n while (numChar--) \n buffer[index++ = Serial.read(); \/\/read serial data and put them in the buffer\n \n splitString(buffer);\n \n if (Serial.available() == NULL) \/\/\n for (int r=1; r<=3; r++) \/\/ if within 3 seconds \n if (Serial.available() == NULL) \/\/ no serial data is detected\n delay (1000); \/\/(thus no settings or no notification) -> activate the function breath\n \n else \/\/ if serial data is detected then stop the process\n break;\n \n \n breath(); \/\/ activate the function called breath (standby fading light pattern)\n \n \n```\nIn this main loop Arduino will listen to the COM port and wait for incoming serial data. In this loop we have put the initiation of our breath() function that will be responsible for the fading pattern during standby period. In fact,<br> if no data is detected within 3 seconds Arduino enters the standby mode and start with the fading pattern. At any moment,<br> as you will see in the next part of the code,<br> if any data is being received over serial (new notifications or new settings) the pattern will stop and Arduino will process the incoming data. \nHowever a very important part has been added to the loop. In fact,<br> we called at the very beginning millis(),<br> which is a function integrated in Arduino boards (thus dont need to declare or define it). When called it returns the number of milliseconds since the Arduino board began running the current program. This call for millis() will be useful later when using the fade effect as it will keep track of the timing for the period of fade and other aspects which will be seen later.\n\n#### 4) Breathing function during standby\n\n```\nvoid breath() \n int redIntensity = 0; \/\/variable to handle the brightness of the RED colour of the RGB led\n int blueIntensity = 0; \/\/variable to handle the brightness of the BLUE colour of the RGB led\n int greenIntensity = 0; \/\/variable to handle the brightness of the GREEN colour of the RGB led\n\nwhile (Serial.available() == NULL) \/\/run below fading pattern till some data is detected over serial\n \n for (int i = 0; i <=240; i+=1) \/\/This loop will light up\/dim linearly the led till it goes from off state to a value close to\n \/\/R=110 G=0 B=255 the starting value for our fading pattern\n\n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \n redIntensity = i\/2;\n blueIntensity = i ;\n \n analogWrite(RedPIN,<br> redIntensity); \/\/\n analogWrite(GreenPIN,<br> greenIntensity); \/\/activate with proper delay the led using the currently stored values for R G B\n analogWrite(BluePIN,<br> blueIntensity); \/\/\n delay(10); \n \n\n for (int t = 0; t<1; t++) \/\/this FOR loop will let use repeat the below (whole) fade-in,<br> fade-out pattern twice\n \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \n for (int i = 110; i <=255; i+=1) \/\/In this for loop we will handle the first transition from R=110 G=0 B=255 (darker Violet) to \n \/\/R=255 G=10 B=255 (much brighter Violet) and have chosen to use the redIntensity as the variable part of the FOR loop\n \/\/based on the value of R = i we will calculate the Green brightness.\n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \n redIntensity = i;\n greenIntensity = ((118937\/10000)*log(i)-(559050\/10000)); \/\/The neperien logarithmic function usually wrote as ln(x) \n \/\/is not recognized in Arduino coding by using ln but log\n \nif(greenIntensity> 10) \/\/based on the aproximation in calculations we do this just in case not to pass the value\n greenIntensity =10;\n \nif(greenIntensity< 1) \/\/based on the aproximation in the calculations this serves to not let\n greenIntensity =0; \/\/the Green pin turns negative \n \n\nanalogWrite(RedPIN,<br> redIntensity); \/\/\nanalogWrite(GreenPIN,<br> greenIntensity); \/\/activate with proper delay the led using the currently stored values for R G B\nanalogWrite(BluePIN,<br> blueIntensity); \/\/\ndelay(10); \/\/\n \n\nfor (int i = 10; i <=220; i+=1) \/\/using this For loop we handle the linear transition between the bright Violet (R=255 G=10 B=255) \n \/\/and the White colour (R=255 G=255 b=255)\n \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \n redIntensity=255;\n blueIntensity=255;\n greenIntensity=i;\n\nanalogWrite(RedPIN,<br> redIntensity); \/\/\nanalogWrite(GreenPIN,<br> greenIntensity); \/\/activate with proper delay the led using the currently stored values for R G B\nanalogWrite(BluePIN,<br> blueIntensity); \/\/\ndelay(10); \/\/\n \n\n\/\/below we reverse the loops used before to fade from Violet to White and use them to do the other way (from White to Violet)\nfor (int i = 220; i >=10; i-=1) \/\/using this For loop we handle the linear transition between the White colour (R=255 G=255 b=255) \n \/\/and the bright Violet (R=255 G=10 B=255)\n \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \n redIntensity=255;\n blueIntensity=255;\n greenIntensity=i;\n\nanalogWrite(RedPIN,<br> redIntensity); \/\/\nanalogWrite(GreenPIN,<br> greenIntensity); \/\/activate with proper delay the led using the currently stored values for R G B\nanalogWrite(BluePIN,<br> blueIntensity); \/\/\ndelay(10); \/\/\n \n\nfor (int i = 255; i >=110; i-=1) \/\/In this for loop we will handle the transition from R=255 G=10 B=255 (much brighter Violet) to \n \/\/ R=110 G=0 B=255 (darker Violet) and as before have chosen to use the redIntensity as the variable part of the FOR loop\n \/\/based on the value of R = i we will calculate the Green brightness.\n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \nredIntensity = i;\ngreenIntensity = ((118937\/10000)*log(i)-(559050\/10000));\n \nif(greenIntensity<1) \/\/based ont he aproximations this will keep us on the safe side.\n greenIntensity =0;\n \nanalogWrite(RedPIN,<br> redIntensity); \/\/\nanalogWrite(GreenPIN,<br> greenIntensity); \/\/activate with proper delay the led using the currently stored values for R G B\nanalogWrite(BluePIN,<br> blueIntensity); \/\/\ndelay(10); \/\/\n \n\nfor (int i = 255; i >=0; i-=1) \/\/This loop will dim linearly the led till it goes totally of\n \/\/since we went back to R=110 G=0 B=255 with a quick calculation and a good aproximation \n \/\/we set the step to take for each brightness decrease so that they get dimmed simultaneously and of the same ammount each time\n\n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \nredIntensity = i\/3;\nblueIntensity = i ;\n \nanalogWrite(RedPIN,<br> redIntensity); \/\/\nanalogWrite(GreenPIN,<br> greenIntensity); \/\/activate with proper delay the led using the currently stored values for R G B\nanalogWrite(BluePIN,<br> blueIntensity); \/\/\ndelay(10); \n \n \n \n\n```\nOnce Arduino will enter the standby mode thus trigger breath() function,<br> this function will continuously loop while no serial data is detected and fade the led between Violet and White (the main colours of Blinkit). As seen in the commented parts of the code,<br> we can see that this light effect,<br> occurring after the WHILE loop,<br> is devided in 5 main parts in the following order:\n\n- Initial FOR loop to do the fading from fully off to R=110 G=0 B=255 which will be the initial colour from which the fading to white will start\n- a FOR loop to repeat the whole fading pattern several times \n- 2 consecutive FOR loops to do the fading from Violet to White as advised above in the study of the mathematical model\n- 2 consecutive FOR loops to do the reverse fading effect (from White to Violet)\n- 1 final FOR loop to slowly turn off\/slowly dim the led from Violet to fully off\n\n\n#### 5) Read splitted data and based on some marker store them in the right setting array\n\n```\n\nvoid setallsettings(char* data) \n \n[... \nif (data[0 == 'E') \/\/if incoming data has marker \"E\" store in an array called EFFECT the effect chosen for each notification\n int blinkdata = strtol(data+1,<br> NULL,<br> 10);\n blinkdata = constrain(blinkdata,<br>1,<br>5); \n transferdata[y = blinkdata;\n y=y+1;\n if (y==3) \/\/ when transferdata is full of data (we expect 3 values,<br> one for each notification)\n memcpy(EFFECT,<br> transferdata,<br> sizeof(transferdata)); \/\/copying transferdata to EFFECT then clearing transferdata and resetting y,<br> \n for (int i=0; i<=sizeof(transferdata); i++) \n transferdata[i = '\\0';\n \n y=0;\n \n \n \nif (data[0 == '?') \/\/send command set to view on serial all the current setups\n Serial.println(\"Current Settings: \");\n Serial.println(\"---------------------------------------------------- \");\n Serial.println(\" \"); \nif(ledmode[0 == 1) \n Serial.println(\"ledmode is set to: 3x single colour LED \");\n Serial.println(\" \"); \n \n for (int i=0;i<=2;i++) \n Serial.print(\"effect for led \");\n Serial.print(i+1);\n Serial.print(\" is set to: \");\n if(EFFECT[i ==1) \n Serial.println(\"NORMAL BLINK\");\n \n if(EFFECT[i ==2) \n Serial.println(\"FADING\");\n \n \n Serial.println(\" \");\n \n for (int i=0;i<=2;i++) \n Serial.print(\"Nofblinks for led\");\n Serial.print(i+1);\n Serial.print(\" is:\");\n Serial.print(Nofblinks[i );\n Serial.println(\" Blinks\");\n if (i==2) \n Serial.println(\" \");\n \n \n for (int i=0;i<=2;i++) \n Serial.print(\"blinkdelay for led \");\n Serial.print(i+1);\n Serial.print(\" is:\");\n Serial.print(blinkdelay[i );\n Serial.println(\" Millis\");\n if (i==2) \n Serial.println(\" \");\n \n \n \n if(ledmode[0 ==2) \n Serial.println(\"ledmode is set to: 1x RGB LED \");\n Serial.println(\" \");\n \n Serial.print(\"number of blinks for upvote trigger is: \");\n Serial.print(Nofblinks[0 );\n Serial.println(\" Blinks\");\n Serial.print(\"number of blinks for follower trigger is: \");\n Serial.print(Nofblinks[1 );\n Serial.println(\" Blinks\");\n Serial.print(\"number of blinks for post trigger is: \");\n Serial.print(Nofblinks[2 );\n Serial.println(\" Blinks\");\n Serial.println(\" \");\n \n Serial.print(\"blinkdelay for upvote trigger is: \");\n Serial.print(blinkdelay[0 );\n Serial.println(\" Millis\");\n Serial.print(\"blinkdelay for follower trigger is: \");\n Serial.print(blinkdelay[1 );\n Serial.println(\" Millis\");\n Serial.print(\"blinkdelay for post trigger is: \");\n Serial.print(blinkdelay[2 );\n Serial.println(\" Millis\");\n Serial.println(\" \");\n \n Serial.println(\"RGB value for upvote trigger is set to\");\n Serial.println(\" \");\n Serial.print(\"R= \");\n Serial.println(BRIGHTU[0 );\n Serial.print(\"G= \");\n Serial.println(BRIGHTU[1 );\n Serial.print(\"B= \");\n Serial.println(BRIGHTU[2 );\n Serial.println(\"\");\n \n if (EFFECT[0 ==1) \n Serial.println(\"Effect for upvote is: NORMAL BLINKING\");\n Serial.println(\" \");\n \n if (EFFECT[0 ==2) \n Serial.println(\"Effect for upvote is: FADING\");\n Serial.println(\" \");\n \n if (EFFECT[0 ==3) \n Serial.println(\"Effect for upvote is: RAINBOW\");\n Serial.println(\" \");\n \n if (EFFECT[0 ==4) \n Serial.println(\"Effect for upvote is: ICE\");\n Serial.println(\" \");\n \n if (EFFECT[0 ==4) \n Serial.println(\"Effect for upvote is: FIRE\");\n Serial.println(\" \");\n \n \n Serial.println(\"RGB value for follower trigger is set to\");\n Serial.println(\" \");\n Serial.print(\"R= \");\n Serial.println(BRIGHTF[0 );\n Serial.print(\"G= \");\n Serial.println(BRIGHTF[1 );\n Serial.print(\"B= \");\n Serial.println(BRIGHTF[2 );\n Serial.println(\"\");\n if (EFFECT[1 ==1) \n Serial.println(\"Effect for follower is: NORMAL BLINKING\");\n Serial.println(\" \");\n \n if (EFFECT[1 ==2) \n Serial.println(\"Effect for follower is: FADING\");\n Serial.println(\" \");\n \n if (EFFECT[1 ==3) \n Serial.println(\"Effect for follower is: RAINBOW\");\n Serial.println(\" \");\n \n if (EFFECT[1 ==4) \n Serial.println(\"Effect for follower is: ICE\");\n Serial.println(\" \");\n \n if (EFFECT[1 ==5) \n Serial.println(\"Effect for follower is: FIRE\");\n Serial.println(\" \");\n \n \n Serial.println(\"RGB value for post trigger is set to\");\n Serial.println(\" \");\n Serial.print(\"R= \");\n Serial.println(BRIGHTP[0 );\n Serial.print(\"G= \");\n Serial.println(BRIGHTP[1 );\n Serial.print(\"B= \");\n Serial.println(BRIGHTP[2 );\n Serial.println(\"\");\n if (EFFECT[2 ==1) \n Serial.println(\"Effect for post is: NORMAL BLINKING\");\n Serial.println(\" \");\n \n if (EFFECT[2 ==2) \n Serial.println(\"Effect for post is: FADING\");\n Serial.println(\" \");\n \n if (EFFECT[2 ==3) \n Serial.println(\"Effect for post is: RAINBOW\");\n Serial.println(\" \");\n \n if (EFFECT[2 ==4) \n Serial.println(\"Effect for post is: ICE\");\n Serial.println(\" \");\n \n if (EFFECT[2 ==5) \n Serial.println(\"Effect for post is: FIRE\");\n Serial.println(\" \");\n \n \n \n \n```\n\nin this part of the sketch we have added the code that will handle the parsing and assignment of the settings for the effect selection made through the interface and have added to the serial feedback lines that will print also the effect chosen for each led.\n\n#### 6) Wait for trigger over serial and activate the realtive LED\n\n```\nvoid setLEDon(char* data) \n \/\/if Arduino receives the command u from serial (upvote detected)\nif (data[0 == 'u') \n if(ledmode[0 ==1) \/\/if ledmode is set to 3 single colour led mode\n if (EFFECT[0 == 1) \/\/ if the effect selected is normal blinking\n for (int a= 0; a< Nofblinks[0 ; a++) \/\/repeat the blinking effect as per the Nofblinks[0 value\n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led whenever data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \/\/do the blinking \n analogWrite(RedPIN,<br> 255); \/\/turn on the led \n delay(blinkdelay[0 );\n analogWrite(RedPIN,<br> 0);\/\/turn off the led\n delay(blinkdelay[0 );\n \n \n if (EFFECT[0 == 2) \/\/ if the effect selected is fading effect\n for (int a= 0; a< Nofblinks[0 ; a++) \/\/repeat the fading effect as per the Nofblinks[0 value\n for (int f=0; f<=255; f++) \n \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \/\/ led will fade in from 0% brightness \/\/\n \/\/ to 100% brightness \/\/\n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n analogWrite(RedPIN,<br> f); \/\/ activate the led\n delay((blinkdelay[0 \/20));\n \n for (int f=255; f>=0; f--) \n \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led whenever data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \/\/ led will fade in from 100% brightness \/\/\n \/\/ 0% brightness back and forth \/\/\n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \n analogWrite(RedPIN,<br> f); \/\/ activate the led\n delay((blinkdelay[0 \/20));\n \n \n \n \n \n if(ledmode[0 ==2) \n if (EFFECT[0 == 1) \/\/ if the effect selected is normal blinking\n for (int a= 0; a< Nofblinks[0 ; a++) \/\/repeat the blinking effect as per the Nofblinks[0 value\n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led whenever data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \/\/do the blinking \n analogWrite(RedPIN,<br> BRIGHTU[0 );\n analogWrite(GreenPIN,<br> BRIGHTU[1 ); \/\/turn on the led using the stored R G B values\n analogWrite(BluePIN,<br> BRIGHTU[2 );\n delay(blinkdelay[0 );\n analogWrite(RedPIN,<br> 0);\n analogWrite(GreenPIN,<br> 0);\/\/turn of the led\n analogWrite(BluePIN,<br> 0);\n delay(blinkdelay[0 );\n \n \n if (EFFECT[0 == 2) \/\/ if the effect selected is fading effect\n unsigned int PERIOD = (blinkdelay[0 *10);\n double OMEGA = 2*PI\/PERIOD; \/\/use a double variable since OMEGA can contain decimals\n int count=1;\/\/ variable to count the number of oscillations\n StartTime= millis();\n \n while (count <= Nofblinks[0 ) \/\/loop to be used to repeat the pattern as per Nofblinks[0 value\n if (Serial.available() > 0) \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when any new data \/\/\n analogWrite(GreenPIN,<br> 0); \/\/ is received and exit the loop \/\/\n analogWrite(BluePIN,<br> 0); \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n break;\n \n \n CurrentTime= millis();\n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \/\/ led,<br> set to an R G B value will fade using a \/\/\n \/\/ sine wave from 0% brightness to 100% brightness \/\/\n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n int FadeRed= ((BRIGHTU[0 \/2) + (BRIGHTU[0 \/2)*(cos(OMEGA*CurrentTime))); \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n int FadeGreen= ((BRIGHTU[1 \/2) + (BRIGHTU[1 \/2)*(cos(OMEGA*CurrentTime))); \/\/ let the value of the brightness oscillate \/\/\n int FadeBlue= ((BRIGHTU[2 \/2) + (BRIGHTU[2 \/2)*(cos(OMEGA*CurrentTime))); \/\/ between 0% and 100% of the set RGB colour \/\/\n \/\/ with the variation of a sine wave \/\/\n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n if ((unsigned long)(millis() - StartTime) >= PERIOD) \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n count++; \/\/ every full oscillation increase the counter and take the current time \/\/\n StartTime= millis(); \/\/ as the new starting point to calculate next period of oscilation \/\/\n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \n analogWrite(RedPIN,<br> FadeRed);\n analogWrite(GreenPIN,<br> FadeGreen);\/\/ activate the led\n analogWrite(BluePIN,<br> FadeBlue);\n \n\n if (count == Nofblinks[0 ) \n analogWrite(RedPIN,<br> 0);\n analogWrite(GreenPIN,<br> 0);\/\/ turn off the led\n analogWrite(BluePIN,<br> 0);\n break;\n \n \n \n\n \nif (EFFECT[0 == 3) \/\/ if the chosen effect for this led is rainbow effect\n int redrainbow;\n int greenrainbow;\n int bluerainbow;\n for (int a= 0; a< Nofblinks[0 ; a++) \/\/repeat the rainbow effect as per the Nofblinks[0 value\n for (int y = 0; y < 768; y++) \n \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led whenever data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n if (y <= 255) \/\/zone1\n redrainbow = 255 - y; \/\/ red goes from on to off\n greenrainbow = y; \/\/ green goes from off to on\n bluerainbow = 0; \/\/ blue is always off\n \n else if (y <= 511) \/\/ zone 2\n redrainbow = 0; \/\/ red is always off\n greenrainbow = 255 - (y - 256); \/\/ green on to off\n bluerainbow = (y - 256); \/\/ blue off to on\n \n else \/\/ color >= 512 \/\/ zone 3\n redrainbow = (y - 512); \/\/ red off to on\n greenrainbow = 0; \/\/ green is always off\n bluerainbow = 255 - (y - 512); \/\/ blue on to off\n \n \n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \/\/ Now that the Intensity values have been set,<br>\/\/\n \/\/ activate the LED with those values \/\/\n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \n analogWrite(RedPIN,<br> redrainbow);\n analogWrite(BluePIN,<br> bluerainbow);\n analogWrite(GreenPIN,<br> greenrainbow);\n delay((blinkdelay[0 \/30)); \n \n \n \n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \/\/ final off after the whole rainbow is done\/\/\n \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n \n delay(500);\n redrainbow = 0; \/\/ red off\n greenrainbow = 0; \/\/ green off\n bluerainbow = 0; \/\/ blue off\n analogWrite(RedPIN,<br> redrainbow);\n analogWrite(BluePIN,<br> bluerainbow);\n analogWrite(GreenPIN,<br> greenrainbow);\n \n \nif (EFFECT[0 ==4) \/\/ if the chosen effect for this led is ice effect\n for (int a= 0; a< Nofblinks[0 ; a++) \/\/repeat the ice effect as per the Nofblinks[0 value\n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \n for (int y=0; y<=240; y++) \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \/\/ fade in till full blue-ice brightness\n analogWrite(GreenPIN,<br> y); \/\/\n analogWrite(BluePIN,<br> y); \/\/\n delay((blinkdelay[0 \/20)); \n \n for (int x=0; x<=255; x++) \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n analogWrite(RedPIN,<br> x); \/\/mix red proportionally to reach white colour\n analogWrite(GreenPIN,<br> 255); \/\/\n analogWrite(BluePIN,<br> 255); \/\/\n delay ((blinkdelay[0 \/20));\n \n for (int z=255; z>=0; z--) \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \n analogWrite(RedPIN,<br> z); \/\/ reverse the action to fade out\n analogWrite(GreenPIN,<br> 255); \/\/\n analogWrite(BluePIN,<br> 255); \/\/\n delay ((blinkdelay[0 \/20));\n \n for (int w=255; w>=0; w--) \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n analogWrite(RedPIN,<br> 0); \/\/ fade out blue ice till all off\n analogWrite(GreenPIN,<br> w); \/\/\n analogWrite(BluePIN,<br> w); \/\/\n delay((blinkdelay[0 \/20)); \n \n \n analogWrite(RedPIN,<br> 0); \/\/ turn off the led\n analogWrite(GreenPIN,<br> 0); \/\/ just to make sure it is off\n analogWrite(BluePIN,<br> 0); \/\/\n \n\n \nif (EFFECT[0 ==5) \/\/ if the chosen effect for this led is fire effect\n for (int a= 0; a< Nofblinks[0 ; a++) \/\/repeat the rainbow effect as per the Nofblinks[1 value\n for (int y=0; y<=255; y++) \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n analogWrite(RedPIN,<br> y);\/\/ fade in till full red brightness\n delay((blinkdelay[0 \/20)); \n \n for (int x=0; x<=40; x++) \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n analogWrite(RedPIN,<br> 255); \/\/mix green proportionally to the red in order to \n analogWrite(GreenPIN,<br> x); \/\/ blend the colours\n delay ((blinkdelay[0 \/20));\n \n \n for (int z=40; z>=0; z--) \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n \n analogWrite(RedPIN,<br> 255); \/\/ reverse the action to fade out\n analogWrite(GreenPIN,<br> z); \/\/\n delay ((blinkdelay[0 \/20));\n \n for (int w=255; w>=0; w--) \n if (Serial.available() > 0) \/\/ \n analogWrite(RedPIN,<br> 0); \/\/turn off the led when data is received and exit the loop\n analogWrite(GreenPIN,<br> 0); \/\/\n analogWrite(BluePIN,<br> 0); \/\/\n break;\n \n analogWrite(RedPIN,<br> w); \/\/ fade out red till off\n delay((blinkdelay[0 \/20)); \n \n \n analogWrite(RedPIN,<br> 0); \/\/ turn off the led\n analogWrite(GreenPIN,<br> 0); \/\/\n \n \n Serial.println(\"you got an upvote \");\n Serial.println(\" \"); \n \n\n\n```\nIn this part the main effects have been coded. I will explain briefly how each new effect works and reiterate the previous effect:\n\n- Normal Blink: as coded previously the led will turn on and off repeatedly\n\n- Fade: If in single led mode the effect is reached by just variating with a for loop the brightness of the specific led. In RGB mode,<br> using the property of millis() a sine wave function (simple harmonic oscillator) has been implemented to handle an oscilation between the led fully off and fully on on the set colour. millis() will have then the very usefull role of keeping track of the time in order to be able to calculate how many oscilation we are doing in order to match the number of blinks\/patterns chosen through the Nofblink on the interface.\n\n- Ice: using some FOR loops we let the RGB value fade from the Aqua color to white colour thus giving the feeling of ice (available only for RGB mode)\n\n- Fire: As per Ice effect we used FOR loops to let the led fade from Red to Orange\/Yellow giving the feeling of a flame (available only for RGB mode)\n\n- Rainbow: a complex calculation has been made in order to go through the entire spectrum of light.This calculation takes in account the different zones and brightness of each led and accordingly activate the led.\n\n\n\n\nThe complete Arduino sketch file (.INO) and all the related information can be downloaded from the Blinkit Github repo [link (https:\/\/github.com\/Electronics-world\/Blinkit-Arduino-integration).\n\n&nbsp;\n\n![ (https:\/\/i.imgur.com\/ShHBzva.jpg)\n\n&nbsp;\n\nIn order to be able to run Arduino with Blinkit,<br> it is a must (as per the current initial release) to firstly upload the sketch using the official [Arduino IDE software (https:\/\/www.arduino.cc\/en\/main\/software). @techtek and I (@electronicsworld) are working on making it possible to upload sketch directly to Arduino boards\/Arduino compatible boards through Blinkit by using some supported features of [Arduino IDE software (https:\/\/www.arduino.cc\/en\/main\/software). \n\n&nbsp;\n\n![ (https:\/\/i.imgur.com\/f8KT7l9.png)\n\n&nbsp;\n\n### The Wiring Diagram\n\nWiring diagram for both ledmode is the same and can be found in my [repo (https:\/\/github.com\/Electronics-world\/Blinkit-Arduino-integration).\n\n\n### The Interface: collaborative testing and implementing\n\nBelow is the new interface that will be comunicating with Arduino. a new combobox has been added in order to select the desired effect based on the ledmode chosen.\n\n![ (https:\/\/i.imgur.com\/qpnKcip.png)\n\nAfter having set all the settings and confirmed what to use,<br> user will have to press save button in order to save the settings and send them to Arduino in order to have it ready to receive new triggers (notice how the standby mode with its pattern stop when you press save as data are being sent to Arduino)\n\nFor full details about how the interface works on the code side and how it has been implemented,<br> please get back to @techtek [post (https:\/\/steemit.com\/utopian-io\/@techtek\/blinkit-2-4-or-rainbow-ice-fire-and-fade-light-effects-added-for-arduino). \n\n## The following files are added to the repository\n\n- [ArduinoBlinkitSketch.ino (https:\/\/github.com\/Electronics-world\/Blinkit-Arduino-integration\/commit\/5c9127961339e80e875db123e228ab7c733202b3#diff-7e370bfa8cdd14c2848c896cb64a811e)\n\n\n&nbsp;\n\n \nMany updates have been planned concerning Arduino integration. In fact our aim is to let Arduino reach a point where it can become fully automated and do not require to be directly attached to a pc running Blinkit software but will run itself the same tasks as Blinkit software by its own thus becoming a portable stand alone device for Steem related notifications.\n\n&nbsp; \n\n### Technical Support\nTechnical support is available,<br> if you may encounter a problem,<br> or if you want to know if your device is supported or will be supported in the near future. \n\n### How to contribute?\nDo you have a question,<br> or suggestion about the integration of Arduino in Blinkit ? Feel free to contact me on Discord (eliaraysalem#0829) or leave a comment below.\n\n\n---",<br>"json_metadata":" \"tags\":[\"utopian-io\",<br>\"development\",<br>\"blinkit\",<br>\"steemdev\",<br>\"arduino\" ,<br>\"users\":[\"techtek\",<br>\"electronicsworld\" ,<br>\"image\":[\"https:\/\/i.imgur.com\/QVv0mJw.png\",<br>\"https:\/\/i.imgur.com\/q4X6I8B.png\",<br>\"https:\/\/i.imgur.com\/oFeTmS9.gif\",<br>\"https:\/\/i.imgur.com\/wJq3gcS.png\",<br>\"https:\/\/i.imgur.com\/ShHBzva.jpg\",<br>\"https:\/\/i.imgur.com\/f8KT7l9.png\",<br>\"https:\/\/i.imgur.com\/qpnKcip.png\" ,<br>\"links\":[\"https:\/\/github.com\/techtek\/Blinkit\",<br>\"https:\/\/utopian.io\/utopian-io\/@techtek\/introducing-blinkit-v2-a-new-user-friendly-interface-to-blink-usb-sticks-and-other-devices-on-steem-related-actions\",<br>\"https:\/\/github.com\/Electronics-world\/Blinkit-Arduino-integration\",<br>\"https:\/\/www.arduino.cc\/en\/main\/software\",<br>\"https:\/\/steemit.com\/utopian-io\/@techtek\/blinkit-2-4-or-rainbow-ice-fire-and-fade-light-effects-added-for-arduino\",<br>\"https:\/\/github.com\/Electronics-world\/Blinkit-Arduino-integration\/commit\/5c9127961339e80e875db123e228ab7c733202b3#diff-7e370bfa8cdd14c2848c896cb64a811e\" ,<br>\"app\":\"steemit\/0.1\",<br>\"format\":\"markdown\" "
* The API used to generate this page is provided by @steemchiller.