3 Replies Latest reply on Apr 8, 2017 12:37 AM by EvPa_264126

    Controlling multiple bidirectional pins through function parameter

      I am working with DHT11 temperature/humidity sensors and have one working like a charm. It uses a one-wire interface, so I need to both read and write the data pin. At the moment I have a function written that calls the pin name directly, but I'm trying to extend this to be able to handle four sensors. Since I have multiple reads/writes within the function I don't want to do an if/else or switch every time I need to access the pin. THe problem is that I don't know how to go about making the function generic so I can pass in the sensor number and have it work only with the correct pin. I looked at the aliases available for pin names, but I can't figure out how (or if it's even possible) to use a function parameter to indicate the correct alias to use with the CyPins_setpin(<alias>) function(s). I also looked at the Mux/Demux, but they are unidirectional so I don't think they'll work. 


      I don't feel like this post is very clear, but I'm having a difficult time coming up with better phrasing. I've attached a rough idea of what I'm trying to accomplish which will, hopefully, clarify things. 


      Any guidance on the correct way to approach this would be great.