Hello everyone,
For school I am supposed to translate a program I wrote to c-code and put it in a c-block in flowcode and it has to run exactly the same.
The problem I am facing is the fact that I need to make a keyboard where each key gives a different voltage to a analog input in the board.
This isn't that much of a issue in flowcode itself cause then you can just add a component macro to read the input as a byte and store it in a variable.
I need to achief the same functionality but then in a C-block.
Does someone knows how to achief this?
Note: I am using flowcode v4
Thanks!
C-code analog input
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: C-code analog input
I am bit confused..Your input will be keyboard i.e., keypad ?The problem I am facing is the fact that I need to make a keyboard where each key gives a different voltage to a analog input in the board.
You will produce output analog voltage for each different key?
Re: C-code analog input
It isnt the keypad from the e-block serie.
The project is supposed to be a little keyboard with keys that go from 0 till 9 and I am only allowed to use 1 analog input to recognize them.
So my idea was to put a voltage divider behind every key and that I would be able to read this value in the PIC board and translate it to a number.
With just flowcode code it is working great but now I have to rewrite it in c-code and get it to work the same.
Now the only part I am confused about is how to read a analog value in c-code.
The project is supposed to be a little keyboard with keys that go from 0 till 9 and I am only allowed to use 1 analog input to recognize them.
So my idea was to put a voltage divider behind every key and that I would be able to read this value in the PIC board and translate it to a number.
With just flowcode code it is working great but now I have to rewrite it in c-code and get it to work the same.
Now the only part I am confused about is how to read a analog value in c-code.
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: C-code analog input
Hello,
For Flowcode v4 first of all compile your existing code to C using the analogue component and then use the View C menu option to look at the code.
The code should contain the ADC functions that get the analogue reading.
Copy the code out of here and paste it into a C icon and you should be about good to go.
For Flowcode v4 first of all compile your existing code to C using the analogue component and then use the View C menu option to look at the code.
The code should contain the ADC functions that get the analogue reading.
Copy the code out of here and paste it into a C icon and you should be about good to go.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: C-code analog input
Hello Ben
I was thinking about that easy solution..But I then thought he might not be using Boostc or HiTech C. May be some other compiler. Definitely the way you told is the best way to learn what I always do to understand. That's why whenever I try to produce anything new in C I try to find what Ben did here in C.
I was thinking about that easy solution..But I then thought he might not be using Boostc or HiTech C. May be some other compiler. Definitely the way you told is the best way to learn what I always do to understand. That's why whenever I try to produce anything new in C I try to find what Ben did here in C.
Re: C-code analog input
Okay I will take a look at that, but now I am wondering is it possible to do this because when I looked at the code before it seems like there are some functions and these functions are called upon in a main loop.
Is it actually possible to reproduce something like this?
Anyway I will have to take a look on it next monday because I don't have any school days till then.
Thanks for the replys and if I can't get it working I will talk with my teacher to chance the project and just leave it as it is!
Thanks!
Is it actually possible to reproduce something like this?
Anyway I will have to take a look on it next monday because I don't have any school days till then.
Thanks for the replys and if I can't get it working I will talk with my teacher to chance the project and just leave it as it is!
Thanks!