I have an inmojo dimmer v2.0
http://www.inmojo.com/store/inmojo-market/item/digital-ac-dimmer-module-lite-v.2/
I have been trying to run the demo code but can’t get it to work. Please help. Here’s the code:
/*
AC Light Dimmer - Inmojo
AC Voltage dimmer with Zero cross detection
Author: Charith Fernanado http://www.inmojo.com charith@inmojo.com
License: Released under the Creative Commons Attribution Share-Alike 3.0 License.
http://creativecommons.org/licenses/by-sa/3.0
Target: Arduino
Attach the Zero cross pin of the module to Arduino External Interrupt pin
Select the correct Interrupt # from the below table
Pin | Interrrupt # | Arduino Platform
2 | 0 | All
3 | 1 | All
18 | 5 | Arduino Mega Only
19 | 4 | Arduino Mega Only
20 | 3 | Arduino Mega Only
21 | 2 | Arduino Mega Only
*/
int AC_LOAD = A0; // Output to Opto Triac pin
int dimming = 128; // Dimming level (0-128) 0 = ON, 128 = OFF
void setup()
{
pinMode(AC_LOAD, OUTPUT); // Set the AC Load as output
attachInterrupt(A1, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
}
void zero_crosss_int() // function to be fired at the zero crossing to dim the light
{
// Firing angle calculation :: 60Hz-> 8.33ms (1/2 Cycle)
// (8333us - 8.33us) / 128 = 65 (Approx)
int dimtime = (65*dimming);
delayMicroseconds(dimtime); // Off cycle
digitalWrite(AC_LOAD, HIGH); // triac firing
delayMicroseconds(8.33); // triac On propogation delay
digitalWrite(AC_LOAD, LOW); // triac Off
}
void loop()
{
dimming = 128;
delay(500);
dimming = 75;
delay(500);
dimming = 25;
delay(500);
}
Do you have the inmojo dimmer v2.0 or something else?
I have an inmojo dimmer v2.0
http://www.inmojo.com/store/inmojo-market/item/digital-ac-dimmer-module-lite-v.2/
I have been trying to run the demo code but can’t get it to work. Please help. Here’s the code:
/*
AC Light Dimmer - Inmojo
AC Voltage dimmer with Zero cross detection
Author: Charith Fernanado http://www.inmojo.com charith@inmojo.com
License: Released under the Creative Commons Attribution Share-Alike 3.0 License.
http://creativecommons.org/licenses/by-sa/3.0
Target: Arduino
Attach the Zero cross pin of the module to Arduino External Interrupt pin
Select the correct Interrupt # from the below table
Pin | Interrrupt # | Arduino Platform
---------------------------------------
2 | 0 | All
3 | 1 | All
18 | 5 | Arduino Mega Only
19 | 4 | Arduino Mega Only
20 | 3 | Arduino Mega Only
21 | 2 | Arduino Mega Only
*/
int AC_LOAD = A0; // Output to Opto Triac pin
int dimming = 128; // Dimming level (0-128) 0 = ON, 128 = OFF
void setup()
{
pinMode(AC_LOAD, OUTPUT); // Set the AC Load as output
attachInterrupt(A1, zero_crosss_int, RISING); // Choose the zero cross interrupt # from the table above
}
void zero_crosss_int() // function to be fired at the zero crossing to dim the light
{
// Firing angle calculation :: 60Hz-> 8.33ms (1/2 Cycle)
// (8333us - 8.33us) / 128 = 65 (Approx)
int dimtime = (65*dimming);
delayMicroseconds(dimtime); // Off cycle
digitalWrite(AC_LOAD, HIGH); // triac firing
delayMicroseconds(8.33); // triac On propogation delay
digitalWrite(AC_LOAD, LOW); // triac Off
}
void loop()
{
dimming = 128;
delay(500);
dimming = 75;
delay(500);
dimming = 25;
delay(500);
}
@letter4vishal,
please try to post your questions on one same thread as posting duplicate only makes it harder for the community to provide advice.
I have shifted your other posts over here and formatted your code for easy reading 
1.) Did you ever get it working on other platforms?
2.) How are you hooking up the board to the spark core?
You need to connect 4 pins:
dimmer --> core
Vcc --> 3.3v
Zero-cross --> A1
Dimmer --> A0
GND --> GND
1 Like
Thankyou. Well no. I don’t have any other platform other than the spark. Although I’ve seen online that most people get it to work on their Arduinos.
Yes This is exactly how I hooked it up.
@letter4vishal, I noticed that the “dimming” is being used in both loop() and the ISR zero_crosss_int(). Ideally, it should be declared as “volatile int dimmer” to avoid any problems. Note also that delayMicroseconds() takes an integer value so a value of 8.33 will be taken as 8. 