OpenWeGrow / UserBot

Source code for Arduino using a GroLab UserBot Shield to interface with the GroLab GroNode. This repository has all the base code to RF interface your Arduino with GroNode using the UserBot Shield by Open Grow™.
https://opengrow.pt/
GNU General Public License v3.0
3 stars 0 forks source link

UserBot adding inputs and outputs #2

Closed sywork42 closed 5 years ago

sywork42 commented 5 years ago

Hi, I found quite hard to add new inputs and outputs to the UserBot as you have to modify a few files of the library so I created a little guide. In this example I added one output led on pin 5 and one input button on pin 6. It's by no means perfect but it will help I hope, don't hesitate to review it and correct it or add some stuff to it:

Change to add new output/inputs

--EEPROM_Utils.cpp,

Add your inputs and outputs types and name ex: " inputs[4].type = BUTTON; strcpy(inputs[4].name, "Button4"); outputs[0].type = LED; strcpy(outputs[0].name, "Led1"); " Find the different types of inputs and outputs in the file "GroBot_Variables.h"

Under "//Clear unused IO's" in : "for(ei=4;ei<10;ei++)" replace ei=4 by the number of inputs that you have in : "for(ei=0;ei<10;ei++)" replace ei=0 by the number of outputs that you have

--SensorsTask.cpp,

Under " //* INPUTS ***// /Here you need to set your used pins as inputs or outputs/ " Add your new pins setting ex: " pinMode(BUTTON_PIN3, INPUT);
pinMode(OUTPUT1_PIN, OUTPUT); "

Under "case GET_IOS:" Add if it's an input something like that: " if (digitalRead(BUTTON_PIN3)) inputs[BUTTON_INDEX3].value = 255; else inputs[BUTTON_INDEX3].value = 0x00; " Or if it's an output: " if (outputs[OUTPUT1_INDEX].value == 0) digitalWrite(OUTPUT1_PIN, LOW);

else digitalWrite(OUTPUT1_PIN, HIGH); "

You can add more "case" for your output and input there

--Grobot_variables.h

Add define more input index and the pin associated ex: "

define BUTTON_INDEX3 3

define BUTTON_PIN3 6

" For the output you have to keep the index unchanged and change the output pin like that: "

define OUTPUT1_PIN 5

"

You have the possible inputs and outputs names you can use at the end of the file

OpenWeGrow commented 5 years ago

Hi @sywork42,

Once again thank you for your contribution.

However, we did some major changes and the instructions you provide are no longer compatible.

But as promised we did the official instructions manual, available in English, Spanish, French, Portuguese, and Italian. We also hope the changes we did to the code also simplifies its usage.

The official GroLab UserBot manual can be found here.

Best regards, Open Grow