How to create a number block in Extension builder with a number output?


#1

I am able to make an extension that shows sets a pin number but how do I set an OUTPUT number to come back from a block?

For example, how do I get the number block to output the value of joyX?

#define joyX A0
 
int xValue = 0;
void setup() {
}
 
void loop() {
  xValue = analogRead(joyX); 
}

Hello @Best_codes, help please?


#2

Put return and then the value:
image


#3

I tried and this is the error I get along with my extension code below.

This is what my code looks like. Did I put the return at the right place?


#4

Hey, @nilashis, I private messaged you about “Your forum use and privacy”. Please check that message out. :slight_smile:

Try putting it here:
image


#5

And could you please give a bit more info about what this block needs to do.


#6

@Best_codes the code is very simple. Basically I want to get the value of an Analog pin A0 back. This is my test block to understand how to return any values.

Question is how should I return the variable xValue ?

#define joyX A0

int xValue = 0;

void setup() {
}

void loop() {
xValue = analogRead(joyX);

}

Think of me just trying to replicate what the following block already does.

image


#7

Where do I find this “Live Mode Handler” in the extension builder? I don’t see it.


#8

Ahh… never mind my previous advice.
This is the code for the block you mentioned:

I have a link to my Arduino UNO + device, which you may look through, as it contains many of such blocks. (Just please don’t steal it :slight_smile:)
https://share.internxt.com/d/sh/file/745beca0dd3fca2eecea/835a6bd5cc1ebf2e746525322705137007dd4c7ef23a194da02c27fd31ed7af9






Download the file, click “Import Data”, and select it:
image

image


#9

IMPORTANT!!!!


#10

@Best_codes Firstly, thanks a MILLION. Your examples are better than all of the documentation out there. Examples are the best way to learn. Don’t worry, I am not trying to do what you did in your extension but your extension code clearly shows me how to write code that I have working in the Arduino IDE that I can now make into blocks.

This is AMAZING! Thanks again!


#11

Great!

P.S.