C/C++ :: Flow Meter - Count Certain Quantity Of Fluid Then Light Up Corresponding LED

May 6, 2014

I am attempting to write some code for a flow meter and LEDs using my Arduino. I need the flow meter to count a certain quantity of fluid, then light up an LED which corresponds to that quantity. I found this code on the internet and it was exactly what I needed but when I opened up the serial monitor to see if it worked it didn't. I have finally fixed the issue with it not counting anything at all, but it is still acting as if it was measuring the rate. how it counts and keeps track of how much fluid in total has passed through the flow meter ?

volatile int NbTopsFan; //variable to accumulate the number of pulses
float Calc = 0; //the volume flowed since measurement started, liters
void pulse() //This is the function that the interupt calls
int hallsensor = 2; //The pin location of the sensor

const int led1Pin = 3; //pin for LED corresponding to volume1
const int led2Pin = 4; //pin for LED corresponding to volume2

[Code] .....

View 13 Replies


ADVERTISEMENT

C++ :: Energy Meter Using Modscan

Mar 26, 2013

I'm using an mbed micro-controller to retrieve register from Integra 1630 energy meter with modbus via a SIPEX SP485CS chip (RS485 level shiftier).

All the component and connection are working correctly.(Double checked) Using the same program with different reigster, i'm able to get good modbus reply from other type of energy meter with modbus. I always a register of 0x00 instead of good modbus reply.

#include "mbed.h"
Serial RS485(p28,p27);
DigitalOut ho(p26);
int regvalue[9];
int main()

[code]....

View 1 Replies View Related

C++ :: Distributing Quantity R In M Boxes

Feb 24, 2014

I have an array of size m and r resources. What would be an efficient (or just any) way of distributing them in the way shown in the table? The highest amount of resources must be concentrated in the middle of the array and all the resources must be distributed.

I'm not really set on exactly how steep the "slope" must be, I just need a way of approaching the problem.

Example with m=9 and r=13

box resources
0 0
1 0
2 2
3 2
4 4
5 2
6 2
7 1
8 0

View 3 Replies View Related

C :: How To Use Accelerometer To Simply Light Up LED At Certain Angle

Mar 17, 2014

I want to use an accelerometer to simply light up an LED at a certain angle. I want to use all three axis each corresponding to a different LED.

I am however getting no change in the LEDs. My code is below.

Code:

#pragma config FOSC = INTIO67, FCMEN = OFF, IESO = OFF // CONFIG1H
#pragma config PWRT = OFF, BOREN = SBORDIS, BORV = 30 // CONFIG2L
#pragma config WDTEN = OFF, WDTPS = 32768 // CONFIG2H
#pragma config MCLRE = OFF, LPT1OSC = OFF, PBADEN = ON, CCP2MX = PORTC // CONFIG3H
#pragma config STVREN = ON, LVP = OFF, XINST = OFF // CONFIG4L

[Code]...

View 6 Replies View Related

C# :: Mvvm Light Constructor Not Being Called

Dec 6, 2014

I can't get my 'Front End' view model's constructor to be called. If i remove my dependency from the mvvm-light framework and use MSDN mvvm paterns then the constructor is called. What am i doing wrong. It seem like there is a data context binding issue between my XMAL and my view model backing.

ViewModelLocator.cs
using GalaSoft.MvvmLight.Ioc;
using Microsoft.Practices.ServiceLocation;
using Point_Of_Sale.Model;
using System.Collections.Generic;
namespace Point_Of_Sale.ViewModel {
public class ViewModelLocator

[Code] ......

View 1 Replies View Related

C# :: Changing Quantity To List Object In Listbox Checkout

Apr 9, 2014

i have a program that is a Mediastore and i have 4 classes. Produkt: which is a class with a few variables that i use to add products to my List.

public class produkt
{
public string Name;
public string price;

[Code]....

then i have my Lager class which i use to add my products to my list and Listbox. This is done by having 3 textfields where i say what the Name,SerialNumber and Price of the object i created should have.

In this class i also have 2 more textfields and a button that make it possible to add a quantity of the selected listbox object of my product Class. if the item im trying to add a quantity to dosent exist i get a question if i wanna add that product and it adds that product to the list. if however the product allready exist its suposed to add the quantity with the selected amount from my textbox.

Then I have my Class Kassa which is a Form with 2 Listboxes. The first listbox share the same List as the one in my Lager class and the other listbox is the listbox which i use to take items from my produktlist and put it in my checkout "basket" then i am suposed to be able to choose one of these items from my checkout basket put the amount i want of that item into a textfield called KvantLEv and press the checkout button to be able to simulate a checkout and then this selected item's quantity is suposed to be lowerd by the specified amount and is to be removed from the checkoutlistbox but this aint working... this is my checkout function so far

private void cashout()
{
produkt p = new produkt();
int a = VaruKorg.Items.Count - 1;

[Code]....

View 7 Replies View Related

Visual C++ :: Program That Count From 1 To 12 And Print Count And Its Square For Each Count

Dec 16, 2014

4.1 Write a program that will count from 1 to 12 and print the count, and its square, for each count.

4.2 Write a program that counts from 1 to 12 and prints the count and its inversion to 5 decimal places for each count. This will require a floating point number.

4.3 Write a program that will count from 1 to 100 and print only those values between 32 and 39, one to a line. Use the incrementing operator for this program.

View 2 Replies View Related

C++ :: Using DirectShow To Control Flow Of A Program

Jul 18, 2014

I am having trouble understanding what I need to do to halt the flow of a program until a video file finishes playing. So far I have accomplished getting the video to play, but the program continues while the video is playing rendering the content of the program on top of the video making it not seen.

My goal is to make the video play, then once it has finished the rest of the program should run.

So far I have this in the start up area of my code:

//Initialize components for DirectShow to stream a video at start-up
CoInitialize(NULL);
//creates filter graph manager

[Code].....

After this code runs once, the program proceeds immediately into the loop where my update and render functions for the program runs. Preferably, I want to stop just the render function while allowing the update to continue to check if the user presses a key to skip the video. What do I need to add to the code to do this?

View 1 Replies View Related

C++ :: Flow Chart For Nested Loop

Jan 6, 2014

how to draw a flow chart for following nested loop?

for(int r=1;r<=5;r++){
for(int c=1;c<=r;++c){
cout<<c;
}
cout<<endl;

View 1 Replies View Related

C++ :: Code Flow (loops And Arrays)

Feb 13, 2013

I am having problems understanding where this code is wrong as I believe that I am not receiving the correct outputs. I have truncated the code to the most pertinent.

The algorithm asks that every value in array1 be divided by array2

and if that value is less than the ratio * array3 (percentage filter) then output.

I have no problem with the code with the exception of abs(ratio*array3[m]

Assuming that the ratio = 1 then all values get outputted, I want the array1 (first value) to have the first value in array3 assigned to it, the second value in array1 to have the second value in array3 to be assigned.

So:

array1 (1.0) with array3 (0.05)
array1 (2.0) with array3 (0.06)
etc.
or
array1 (1.0) with array3 (0.05)
array1 (3.0) with array3 (0.07)

Code:
array1[5] = {1.0, 2.0, 3.0, 4.0, 5.0};
array2[5] = {1.0, 2.0, 3.0, 4.0, 5.0};
array3[5] = {0.05, 0.06, 0.07, 0.08, 0.09};
ratio = abc/def;
for(int m=0; m<5; m++) {

[code]...

View 2 Replies View Related

C++ :: Writing Pseudo Code And Flow Charts

Apr 15, 2013

I have finished writing the code for the following program. I have concerns with the pseudo-code that I have written and the flow chart seems really complicated. I dont know how to build it. Here is the question:

An Internet service provider has three different subscription packages for its customers:
Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.
Package B: For $14.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month unlimited access is provided.

Write a program that calculates a customer s monthly bill. It should ask which package the customer has purchased and how many hours were used. It should then display the total amount due.

Input Validation: Be sure the user only selects package A, B, or C. Also, the number of hours used in a month cannot exceed 744

Here is my program:
#include <iostream>
using namespace std;
int main() {
char package;
int hours;

[code]....

What should be my pseudocode and flowchart ? Can i copy and paste my pseudocode here ?

View 2 Replies View Related

C++ :: For Loop To Count Down From 10 To 0

Apr 16, 2013

I am using a for loop to count down from 10 to 0 it's working to count down from 10 to 1 but when the program cames to the 0 then the program freezes by any reason.

Code:
#include <iostream>
using namespace std;
int main()
{
int number[2];
cout << "Enter number: ";
cin >> number[0];
if (number[0] == 1)

[Code] ....

View 11 Replies View Related

C++ :: How To Count Letters

Mar 16, 2013

I'm just trying to find out if the way I've setup my code currently allows me to count the letters as they occur? I don't yet see how to do it but I need clarification. Ideally the function letterCounter would do the counting but atm I'm just trying to figuring it out in the display function.

View 2 Replies View Related

C/C++ :: Print To LCD - Count Up To 100 Then Down To 1

Feb 12, 2014

I have the following code to print a string to the LCD using my PIC32 Starter Kit; I have made this code work with success. I cannot, however, make the LCD print numbers.

#include<p32xxxx.h>
#define LCD_PRT PORTE //LCD DATA PORT
//#define LCD_DDR DDRE//LCD DDR
//#define LCD_PIN PINE//LCD PIN

[Code].....

I want to change the original code as little as possible, don't worry about my header files - they are fine.

View 2 Replies View Related

C/C++ :: Cannot Count 2D String

Mar 16, 2015

i couldn't count the 2d string. my string is list[100][100] = {"Batuhan","Jeyhun","Tashtanbek"} this is a food line in cafeteria. i want to add a person to this list but i couldnt do it because i dont know the length of my list. it will be more than 3 after i add a person but what if i would add another person after that ? In that case i couldnt be able to tell how long is my line.And after i add people to my list i want to print that list. here is where i came so far:

case 1:
printf("Enter the name of the person to be added
");
printf(">>");
k=0;

[Code].....

View 4 Replies View Related

C++ :: Count The Repeated Numbers?

Jul 12, 2013

I am using this code that to check a set of values from a text file and show it on the output.

Code: void MatchNumber(int b) {
vector<Rect> rects;
ifstream theFile("CheckNumber.txt");
double x1,y1,x2,y2;
while(theFile >> x1 >> y1 >> x2 >> y2 ){
rects.push_back(Rect(x1,y1, x2,y2));
}
int num=0;

[code]....

I want to calculate how many times the common number is repeated . So I have used freq[num] in that function. But I am getting the output like this-

Code:

The common number is = 5
The 5 repeated = 1 times
The common number is = 6
The 6 repeated = 1 times

The common number is = 4
The 4 repeated = 1 times

The common number is = 5
The 5 repeated = 1 times

[code]....

So the freq[num] is only returning 1 instead of counting the total number of repeating which is wrong!! I would like to have somthing like this in my output -

Code:

The common number is = 5
The common number is = 6
The common number is = 4
The common number is = 5
The common number is = 5
The common number is = 8
The common number is = 9
The common number is = 6
The common number is = 6

[code]....

How can I do that?

View 3 Replies View Related

C++ :: How To Count Sentences In A Paragraph

Oct 2, 2013

a sample program using c language on how to count sentences in a paragraph...

View 3 Replies View Related

C++ :: Count Backward From 100 To 1 In Increments Of 10

Nov 5, 2014

The question is Create a counting program that counts backward from 100 to 1 in increments of 10.

#include <iostream>
using namespace std;
int main() {
int num = 1;
while (num<100) {

[Code] ....

It seems there are some errors.

View 1 Replies View Related

C++ :: Letter Frequency Count

Nov 13, 2013

I am new to c++. I am writing a program that reads in a text file and gives a count of how many times each letter appeared in the file. I got it to read the text file and do the letter count. B

X = 102
Y = 126
Z = 165
etc...

THAT IS WORNG

The sample output should be
E = 165
T = 126
A = 102
O = 93
etc...

I got it to sort from lowest to highest for the frequency, but cant seem to get the appropriate letter assigned to it.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

[code].....

View 1 Replies View Related

C++ :: How To Count Same Numbers Once In Array

Jan 22, 2015

iam trying to count the same numbers in an array just once like

38
38
40
38
40
37

the output should be 2 since 38 is repeated and 40 too but for my code the output is 3 thats an example of how it should be in a nutshell i want same number to be counted just once in the whole array

and here's my code :

#include <iostream>
using namespace std;
int main(){

[Code].....

View 11 Replies View Related

C++ :: Count The Numbers Below The Average

Mar 7, 2013

I have loaded and 1d array from a .dat file, calculated the average of all the numbers. Now I need to count every number in the array that is below the average and cout that number. This is the method in the class I have so far:

int IntegerArray::countBelowAverage(int numBelowAvg) {
avg=IntegerArray::getAvg();
for(int ct=0; ct<avg; ++ct) {
numBelowAvg=ct;
}
return numBelowAvg;
}

My output from this is always 0 and I know that there are numbers below the avg.

View 2 Replies View Related

C++ :: Program That Can Count Space?

Jun 8, 2013

I was coding a program that can count space, new_line, and other characters in a paragraph, but it doesn't work.

#include <stdio.h>
int main(void)
{

[Code].....

View 1 Replies View Related

C++ :: Reference Count Of Object?

Jun 24, 2014

I have a question regarding reference count of an object. How i'll be able to know that how many pointers are pointing to my object.....

View 3 Replies View Related

C++ :: How To Put 2 Letters Together And Make Them To Count As 1

Mar 11, 2013

how to put 2 letters together and make them to count as 1?

provided that they must consecutive

for example:

p : count as 0
pxp : count as 0
pp : count as 1
xpxp: count as 0
ppxpp : count as 2

View 1 Replies View Related

C/C++ :: How To Count Values In Struct

Nov 6, 2014

I want to count values in a struct.

typedef struct {
  int x;
  int test;
}TYPE_TEST;  
TYPE_TEST My[6] ={
    {16, 50},
    {4,  51},
    {50, 52},
    {47, 53},
    {10, 54},
    {19, 55}
};

int Newbuffer[ ????? ]  

Now I want to make the size of Newbuffer the sum of all "x", that is 146. Not the size of X.

But how to sum all "x".

View 5 Replies View Related

C :: Append Integer To Char As A Count

Apr 15, 2014

I am trying to keep a count on a variable name stored within a structure as char*'s. They are of the same field and I do not know how many there will be so I would like to keep a standard name and append the count.

So say I have a variable name such as "desk", but as I have many of these said desks so I would like to call them "desk1", "desk2", "desk3" and so forth. Any recommendations on how I could do this?

Also since this is somewhat relevant is there an easy way to convert from an integer to a string, something that would work like atoi() in reverse? I wouldn't mind writing a method to do so myself but haven't a clue as to how.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved