Exemplo n.º 1
0
int main(int argc, char **argv)
{
	setupUUGear();
	
	setShowLogs(0);
	
	UUGearDevice dev = attachUUGearDevice ("UUGear-Arduino-7853-2668");
	
	if (dev.fd != -1)
	{
		int i;
		for (i = 0; i < 200; i ++)
		{
			float value = readSR04(&dev, 4, 4);
			printf("Distance = %f cm\n", value);
			sleep(1);
		}
		detachUUGearDevice (&dev);
	}
	else
	{
		printf("Can not open UUGear device.\n");	
	}

	cleanupUUGear();
		
    return 0;
}
Exemplo n.º 2
0
/* 
 This example read humidity and temperature from DHT11 or DHT22 sensor
*/
int main(int argc, char **argv)
{
	setupUUGear();
	
	setShowLogs(0);
	
	UUGearDevice dev = attachUUGearDevice ("UUGear-Arduino-7853-2668");
	
	if (dev.fd != -1)
	{
		int i;
		for (i = 0; i < 200; i ++)
		{
			time_t mytime = time(NULL);
			int data = readDHT(&dev, 4);
			float humidity = ((float)(data >> 16)) / 10;
			if ( humidity > 100 )
			{
				humidity = (data >> 24);	// for DHT11
			}
			float temperature = ((float)(data & 0x7FFF)) / 10;
			if ( temperature > 125 ) 
			{
				temperature = ((data & 0x7F00) >> 8);	// for DHT11
			}
Exemplo n.º 3
0
int main(int argc, char **argv)
{

    setShowLogs(1);

    DomoDevice dev = attachDomoDevice ("DomoSy-Arduino-1633-3668");


    if (dev.fd != -1 )
    {
      setMasterButton(&dev, pinMap[12]);
        setPinAsButton(&dev, pinMap[12]);
        char* response;
        int errorcode;
        response=waitForStringBlock(&dev, &errorcode);
        if (atoi(response)==pinMap[12])
        {
            setPinModeAsOutput (&dev, pinMap[13]); // for debug
			sleep(1);
            setPinHigh (&dev, pinMap[13]);
            usleep(0.5*1000*1000);
            setPinLow (&dev, pinMap[13]);
        }
    }
    else
    {
        printf("Can not open device.\n");
    }

	detachDomoDevice (&dev);


    return 0;
}
Exemplo n.º 4
0
int main(int argc, char **argv)
{

setShowLogs(1);

DomoDevice dev = attachDomoDevice ("DomoSy-Arduino-5141-9267");

DomoDevice dev2 = attachDomoDevice ("DomoSy-Arduino-1633-3668");
if (dev.fd != -1 && dev2.fd != -1 )
{
setPinModeAsOutput (&dev, 22);
setPinModeAsOutput (&dev, 23);
setPinModeAsInput (&dev2, 22);
setPinModeAsOutput (&dev2, 23);
int i = 0;
/*for (i = 0; i < 5; i ++)
{
setPinHigh (&dev, 23);
setPinLow (&dev2, 23);
sleep(2);

setPinHigh (&dev2, 23);
setPinLow (&dev, 23);
sleep(2);



}*/
setPinHigh (&dev, 23);
 sleep(2);
setPinHigh (&dev, 22);
setPinLow (&dev, 23);
printf("Pin status=%d\n", getPinStatus(&dev2, 22));
 if (getPinStatus(&dev2, 22)==1) 
setPinHigh (&dev2, 23);
sleep(2);
setPinLow (&dev, 23);



detachDomoDevice (&dev);
detachDomoDevice (&dev2);
}
else
{
printf("Can not open UUGear device.\n");	
}

//cleanupDomo();

    return 0;
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
	setupUUGear();
	
	setShowLogs(0);
	
	/* replace the device id with yours (listed by lsuu) */
	UUGearDevice dev = attachUUGearDevice ("UUGear-Arduino-9886-9947");
	
	if (dev.fd != -1)
	{
		/* attach servo on pin 4 */
		attachServo(&dev, 4);
		
		/* move servo to 30 degrees */
		writeServo(&dev, 4, 30);
		
		/* give some time to move */
		sleep(1);
		
		/* move servo to 90 degrees */
		writeServo(&dev, 4, 90);
		
		/* give some time to move */
		sleep(1);
		
		/* detach servo */
		detachServo(&dev, 4);
		
		detachUUGearDevice (&dev);
	}
	else
	{
		printf("Can not open UUGear device.\n");	
	}

	cleanupUUGear();
		
    return 0;
}
Exemplo n.º 6
0
int main(int argc, char **argv)
{
	setupUUGear();
	
	setShowLogs(1);
	
	UUGearDevice dev = attachUUGearDevice ("UUGear-Arduino-7853-2668");
	
	if (dev.fd != -1)
	{
		double begin, end;
		
		begin = getCurTime();
		int value = analogRead(&dev, 3);
		end = getCurTime();
		printf("Analog read on A3 takes %f ms, value=%d\n", end - begin, value);
		
		begin = getCurTime();
		setPinModeAsInput (&dev, 9);
		end = getCurTime();
		printf("Set pin mode on D9 takes %f ms\n", end - begin);
		
		begin = getCurTime();
		value = getPinStatus(&dev, 9);
		end = getCurTime();
		printf("Digital read on D9 takes %f ms, value=%d\n", end - begin, value);			
		
		detachUUGearDevice (&dev);
	}
	else
	{
		printf("Can not open UUGear device.\n");	
	}

	cleanupUUGear();
		
    return 0;
}
Exemplo n.º 7
0
int main(int argc, char **argv)
{
if(argc != 3 ) { 
	printf("Erreur d'argument, utilisation : ./Switch DomoSy-... numPinDigital \n");
	return -1 ;
	}


setShowLogs(1);

DomoDevice dev = attachDomoDevice (argv[1]);

int pin=pinMap[atoi(argv[2])];
if (dev.fd != -1 )
{
//  setPinModeAsOutput (&dev, pin); // for debug

setPinTorchDown(&dev, pin);
}
detachDomoDevice (&dev);

    return 0;
}