2

I can use digital pins from 1-13 as usual. For example

relays.firstRelay = new five.Relay ( {
pin:13,
type:'NO'
});

But I am unable to set pin:14. I don't get any output.

Is there a way to set A0 as digital pin and use it in relay?

I am using Arduino Uno

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
Gokhan Dilek
  • 4,314
  • 4
  • 21
  • 24
  • 2
    You need to indicate the hardware you are working on. – Jason K. Mar 29 '17 at 14:26
  • I am sorry. I have just added that info as well. – Gokhan Dilek Mar 29 '17 at 14:27
  • I looked at the schematic for the board https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf What are you considering pin:14? The pinout on the lower right corner is showing pins up to 13. – Jason K. Mar 29 '17 at 14:39
  • I am considering A0 to A5 as digital pins. So A0 as pin14 http://www.digikey.com/Web%20Export/techzone/microcontroller/article-2012january-arduinos-analog-functions-fig2.jpg – Gokhan Dilek Mar 29 '17 at 14:44
  • Have you set up the pin settings so that you are not generating a PWM signal instead of the digital output that you want? Did you set pinmode to OUTPUT? – Jason K. Mar 29 '17 at 15:06
  • I need to create a pin14 object like this: analogPinsToDigitalPins.pin14 = new five.Pin({ pin:14, type: 'digital' }); Then pass it to pin property of the relay. Can I do that? – Gokhan Dilek Mar 29 '17 at 15:12

1 Answers1

0

On the UNO, the analog pins will need to be treated a bit differently because of the need to set their pin type. But otherwise having an array of pin objects should be fine. You just need to get the analog pins setup early as operating digitally instead. You may also want to try addressing the pin as A0 instead of 14.

Jason K.
  • 790
  • 1
  • 14
  • 22
  • I am referring to this documentation regarding pin class. https://github.com/rwaldron/johnny-five/wiki/Pin It does not use A0 while using the analog pins as digital. I also set A0 as pin14 but i was not able to use it in the relay object. – Gokhan Dilek Mar 29 '17 at 15:21
  • If you did the following from that documentation and still have issues, then I am not sure how that code is specifically implementing the need to set the pin type:// Analog As Digital new five.Pin({ pin: 14, type: "digital" }); It might be worth simply trying to set the pin directly outside of the settings made in that code base. – Jason K. Mar 29 '17 at 15:51
  • Not sure what you mean. Can you try to use the relay with analog pins? Does it work? – Gokhan Dilek Mar 29 '17 at 16:22
  • I am away from the IDE at the moment but what I was referring to was that there is a section Component Initialization on page https://github.com/rwaldron/johnny-five/wiki/Pin that outlines how to use an analog pin as digital and requires the addition of the digital type to the pin. – Jason K. Mar 29 '17 at 18:15
  • Still getting nowhere with this. Cannot use the analog pins for relay :) – Gokhan Dilek Apr 15 '17 at 08:54