Hi all
I am using MatLab to control a Arduino Mega 2560. I am using the analogwrite() function to write a PWM duty cycle value to the output pins. I would like to use 7 outputs but when I try to use a pin e.g. 4 I receive the following error message:
Unallowed value for pwm pin number, the value must be one of the following: [3 5 6 9 10 11]
Unfortunately there are only 6 available pins here! I attempted to modify the arduino.m file as well as the adiosrv.pde file in the following way (advised in the readme.txt file for working with an Arduino Mega board and MatLab):
-
In the file 'arduino.m', replace every occurrence of
errstr=arduino.checknum(pin,'pin number',2:19);
with:
errstr=arduino.checknum(pin,'pin number',2:69);
replace every occurrence of:
errstr=arduino.checknum(pin,'analog input pin number',0:5);
with:
errstr=arduino.checknum(pin,'analog input pin number',0:15);
then replace every occurrence of:
for i=2:19,
with
for i=2:69,
and finally replace :
a.pins=-1ones(1,19);
with:
a.pins=-1ones(1,69); -
In the file 'srv.pde', change every occurrence of
if (val>98 && val <117) {
with the following:
if (val>98 && val <167) {
(basically replace 117 with 167)
and also change the line
if (val>96 && val <103) {
with the line
if (val>96 && val <113) {
(basically replace 103 with 113).
However, I still received the same error message.
I would be very grateful for some help with this issue!