Difference between revisions of "Single Color LED (use with mDesigner)"

From Microduino Wiki
Jump to: navigation, search
(Set Pin)
(Set Pin PWM)
 
(45 intermediate revisions by the same user not shown)
Line 1: Line 1:
The Single Color LED is a light emitting diode (LED), which is capable of emitting a illuminating a single color. Red, green and yellow are the common colors. Support for this trinket is found in mDesigner.
+
The Single Color LED is a light emitting diode (LED), which is capable of illuminating a single color. Red, green and yellow are the common colors. Support for this trinket is found in mDesigner.
  
 
=Compatible Pins=
 
=Compatible Pins=
The following pins on the Hub or mCenter+'s Hub support this module:
+
The following pins on the '''Hub''' or '''mCenter+'s Hub''' support this module:
==Hub==
+
<div style="width: 80%;">
{| class="wikitable"
+
<div style="float: left;">[[File:Hub_Digital_Pins_v2-01.png|thumb|600px]]</div>
 +
<div style="float: left;">
 +
{| class="wikitable" style="text-align: left;"
 
|-
 
|-
 
! scope="col"| Pin Name
 
! scope="col"| Pin Name
Line 10: Line 12:
 
! scope="col"| Notes
 
! scope="col"| Notes
 
|-
 
|-
! scope="col" | Pin 0
+
| '''Pin 0'''
| Yes
+
| style='background: #FEF9E7' | Yes
| Not recommended, since Pin 0 & 1 are used by mDesigner (serial communication).
+
| Not recommended, Pin 0 & 1 used by mDesigner (serial communication).
 
|-
 
|-
! scope="col" | Pin 1
+
| '''Pin 1'''
| Yes
+
| style='background: #FEF9E7' | Yes
| Not recommended, since Pin 0 & 1 are used by mDesigner (serial communication).
+
| Not recommended, Pin 0 & 1 used by mDesigner (serial communication).
 +
|-
 +
| '''Pin 2'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 3'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 4'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 5'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 6'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 7'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 8'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 9'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 10'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 11'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 12'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin 13'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin A0'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin A1'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin A2'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin A3'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin A6'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin A7'''
 +
| style='background: #EAFAF1' | Yes
 +
|
 +
|-
 +
| '''Pin I2C'''
 +
| style='background: #FDEDEC' | No
 +
|
 
|}
 
|}
 +
 +
</div>
 +
<br style="clear: left;" />
 +
</div>
  
 
=Blocks=
 
=Blocks=
The follow blocks are used for this module.
 
 
==Set Pin==
 
==Set Pin==
[[File:mDesigner_Block_Set_Pin_(Digital)]]
+
This block sets the voltage level on the selected pin either to '''high''' or '''low'''. In Arduino, this is know as a digital write (digitalWrite).
This block sets the voltage level on the selected pin either to '''high''' or '''low'''.
 
 
*When set to '''high''', the Single Color LED turns on (illuminates).
 
*When set to '''high''', the Single Color LED turns on (illuminates).
 
*When set to '''low''', the Single Color LED turns off (no illumination).
 
*When set to '''low''', the Single Color LED turns off (no illumination).
===Examples===
+
::[[File:mDesigner_Block_Set_Pin_(Digital).png]]
 +
:*'''Pin Number''' - the pin to configure the state of.
 +
:*'''State '''- set the pin to "high" or "low" state.
 +
===Examples Uses===
 +
'''Software Setup for Examples'''
 +
*Setup your software for either [[null|Live Mode]] or [[null|Arduino Mode]].
 +
'''Hardware Setup for Examples'''
 +
[[]]
 +
 
 +
*'''Example 1:''' Turn '''off''' the Single Color LED connected to pin 6.
 +
::[[File:MDesigner_Block_Set_Pin_(Digital)_Example1.png]]
 +
 
 +
 
 +
*'''Example 2:''' Turn '''on''' the Single Color LED connected to pin 6.
 +
::[[File:MDesigner_Block_Set_Pin_(Digital)_Example2.png]]
 +
 
 +
 
 +
*'''Example 3:''' Turn '''on''' the Single Color LED connected to pin 6, wait 1 second, then turn off, wait another second, then loop repeatedly.
 +
::[[File:MDesigner_Block_Set_Pin_(Digital)_Example3.png]]
  
 
==Set Pin PWM==
 
==Set Pin PWM==
This block sets the voltage level on the selected pin varying values.
+
This block sets the voltage level on the selected pin varying values. In Arduino, this is known as an analog write (analogWrite).
 
Values between 0 and 255 will cause the Single Color LED to turn on at different levels.
 
Values between 0 and 255 will cause the Single Color LED to turn on at different levels.
 
*When set to 255, the Single Color LED is at maximum on.
 
*When set to 255, the Single Color LED is at maximum on.
*When set to 0, the Single COlor LED is off.
+
*When set to 0, the Single Color LED is off.
 
*When set to 127, the Single Color LED is half-way on.
 
*When set to 127, the Single Color LED is half-way on.
 
*Other values between 0 and 255 will turn on the LED at appropriate brightness levels.
 
*Other values between 0 and 255 will turn on the LED at appropriate brightness levels.
  
'''*Note: Only pins which support "Analog Write" will work correctly with this block.'''
+
{| class="wikitable" style="background-color:#FEF9E7;"
*For Microduino / mCookie Core: Pins A, B, C
+
|'''Note: Only pins which support "Analog Write" will work correctly with this block.'''<br>*For Microduino / [[MCookie-Core|mCookie Core]]: Pins 3, 5, 6, 9, 10, and 11<br>*For Microduino / [[MCookie-Core%2B|mCookie Core+]], mCenter+:  Pins 7, 8, 9, 10, 12, 13, 22, and 23
*For Microduino / mCookie Core+, mCenter+:  Pins D, E, F
+
|}
 +
::[[File:MDesigner_Block_Set_Pin_(PWM).png]]
 +
:*'''Pin Number''' - the pin to configure the state of. Note: Only certain pins support this ability. See above for which pins has this ability in your hardware setup.
 +
:*'''Value''' - the value between 0 and 255 to set the pin to.
 +
 
 +
===Examples Uses===
 +
'''Software Setup for Examples'''
 +
*Setup your software for either [[null|Live Mode]] or [[null|Arduino Mode]].
 +
'''Hardware Setup for Examples'''
 +
[[]]
 +
 
 +
*'''Example 1:''' Turn '''off''' the Single Color LED connected to pin 6.<br>('''Note''': Change the pin number to one that supports this block, see yellow box above)
 +
::[[File:MDesigner_Block_Set_Pin_(PWM)_Example1.png]]
 +
 
 +
 
 +
*'''Example 2:''' Fully turn '''on''' the Single Color LED connected to pin 6.<br>('''Note''': Change the pin number to one that supports this block, see yellow box above)
 +
::[[File:MDesigner_Block_Set_Pin_(PWM)_Example2.png]]
 +
 
 +
 
 +
*'''Example 3:''' Turn the Single Color LED half way on ('''127''' out of 255 ~= 0.5) connected to pin 6.<br>('''Note''': Change the pin number to one that supports this block, see yellow box above)
 +
::[[File:MDesigner_Block_Set_Pin_(PWM)_Example3.png]]
 +
 
 +
 
 +
*'''Example 4:''' Turn the Single Color LED connected to pin 6 full on ('''255'''), wait 1 second, then set half way on ('''127'''), wait another second, then loop repeatedly.<br>('''Note''': Change the pin number to one that supports this block, see yellow box above)
 +
::[[File:MDesigner_Block_Set_Pin_(PWM)_Example4.png]]

Latest revision as of 18:00, 7 June 2018

The Single Color LED is a light emitting diode (LED), which is capable of illuminating a single color. Red, green and yellow are the common colors. Support for this trinket is found in mDesigner.

Compatible Pins

The following pins on the Hub or mCenter+'s Hub support this module:

Hub Digital Pins v2-01.png
Pin Name Compatibility Notes
Pin 0 Yes Not recommended, Pin 0 & 1 used by mDesigner (serial communication).
Pin 1 Yes Not recommended, Pin 0 & 1 used by mDesigner (serial communication).
Pin 2 Yes
Pin 3 Yes
Pin 4 Yes
Pin 5 Yes
Pin 6 Yes
Pin 7 Yes
Pin 8 Yes
Pin 9 Yes
Pin 10 Yes
Pin 11 Yes
Pin 12 Yes
Pin 13 Yes
Pin A0 Yes
Pin A1 Yes
Pin A2 Yes
Pin A3 Yes
Pin A6 Yes
Pin A7 Yes
Pin I2C No


Blocks

Set Pin

This block sets the voltage level on the selected pin either to high or low. In Arduino, this is know as a digital write (digitalWrite).

  • When set to high, the Single Color LED turns on (illuminates).
  • When set to low, the Single Color LED turns off (no illumination).
MDesigner Block Set Pin (Digital).png
  • Pin Number - the pin to configure the state of.
  • State - set the pin to "high" or "low" state.

Examples Uses

Software Setup for Examples

Hardware Setup for Examples [[]]

  • Example 1: Turn off the Single Color LED connected to pin 6.
MDesigner Block Set Pin (Digital) Example1.png


  • Example 2: Turn on the Single Color LED connected to pin 6.
MDesigner Block Set Pin (Digital) Example2.png


  • Example 3: Turn on the Single Color LED connected to pin 6, wait 1 second, then turn off, wait another second, then loop repeatedly.
MDesigner Block Set Pin (Digital) Example3.png

Set Pin PWM

This block sets the voltage level on the selected pin varying values. In Arduino, this is known as an analog write (analogWrite). Values between 0 and 255 will cause the Single Color LED to turn on at different levels.

  • When set to 255, the Single Color LED is at maximum on.
  • When set to 0, the Single Color LED is off.
  • When set to 127, the Single Color LED is half-way on.
  • Other values between 0 and 255 will turn on the LED at appropriate brightness levels.
Note: Only pins which support "Analog Write" will work correctly with this block.
*For Microduino / mCookie Core: Pins 3, 5, 6, 9, 10, and 11
*For Microduino / mCookie Core+, mCenter+: Pins 7, 8, 9, 10, 12, 13, 22, and 23
MDesigner Block Set Pin (PWM).png
  • Pin Number - the pin to configure the state of. Note: Only certain pins support this ability. See above for which pins has this ability in your hardware setup.
  • Value - the value between 0 and 255 to set the pin to.

Examples Uses

Software Setup for Examples

Hardware Setup for Examples [[]]

  • Example 1: Turn off the Single Color LED connected to pin 6.
    (Note: Change the pin number to one that supports this block, see yellow box above)
MDesigner Block Set Pin (PWM) Example1.png


  • Example 2: Fully turn on the Single Color LED connected to pin 6.
    (Note: Change the pin number to one that supports this block, see yellow box above)
MDesigner Block Set Pin (PWM) Example2.png


  • Example 3: Turn the Single Color LED half way on (127 out of 255 ~= 0.5) connected to pin 6.
    (Note: Change the pin number to one that supports this block, see yellow box above)
MDesigner Block Set Pin (PWM) Example3.png


  • Example 4: Turn the Single Color LED connected to pin 6 full on (255), wait 1 second, then set half way on (127), wait another second, then loop repeatedly.
    (Note: Change the pin number to one that supports this block, see yellow box above)
MDesigner Block Set Pin (PWM) Example4.png