Example #1
0
void TLC5940_SetGS_And_GS_PWM(void) {
    uint8_t firstCycleFlag = 0;

    if (outputState(VPRG_PORT, VPRG_PIN)) {
        setLow(VPRG_PORT, VPRG_PIN);
        firstCycleFlag = 1;
    }

    uint16_t GSCLK_Counter = 0;
    uint8_t Data_Counter = 0;

    setLow(BLANK_PORT, BLANK_PIN);
    for (;;) {
        if (GSCLK_Counter > 4095) {
            setHigh(BLANK_PORT, BLANK_PIN);
            pulse(XLAT_PORT, XLAT_PIN);
            if (firstCycleFlag) {
                pulse(SCLK_PORT, SCLK_PIN);
                firstCycleFlag = 0;
            }
            break;
        } else {
            if (!(Data_Counter > TLC5940_N * 192 - 1)) {
                if (gsData[Data_Counter])
                    setHigh(SIN_PORT, SIN_PIN);
                else
                    setLow(SIN_PORT, SIN_PIN);
                pulse(SCLK_PORT, SCLK_PIN);
                Data_Counter++;
            }
        }
        pulse(GSCLK_PORT, GSCLK_PIN);
        GSCLK_Counter++;
    }
}
Example #2
0
void TLC5940_Init(void) {
	setOutput(GSCLK_DDR, GSCLK_PIN);
	setOutput(SCLK_DDR, SCLK_PIN);
	setOutput(DCPRG_DDR, DCPRG_PIN);
	setOutput(VPRG_DDR, VPRG_PIN);
	setOutput(XLAT_DDR, XLAT_PIN);
	setOutput(BLANK_DDR, BLANK_PIN);
	setOutput(SIN_DDR, SIN_PIN);
	
	setLow(GSCLK_DDR, GSCLK_PIN);
	setLow(SCLK_PORT, SCLK_PIN);
	setLow(DCPRG_PORT, DCPRG_PIN);
	setHigh(VPRG_PORT, VPRG_PIN);
	setLow(XLAT_PORT, XLAT_PIN);
	setHigh(BLANK_PORT, BLANK_PIN);

	// CTC with OCR0A as TOP
	TCCR0A = (1 << WGM01);
	// clk_io/1024 (From prescaler)
	TCCR0B = ((1 << CS02) | (1 << CS00));
	// Generate an interrupt every 4096 clock cycles
	OCR0A = 3;
	// Enable Timer/Counter0 Compare Match A interrupt
	TIMSK0 |= (1 << OCIE0A);
}
Example #3
0
int PS2Emu::devRead(unsigned char *ret) {
    unsigned char data = 0x00;
    unsigned char p = 0x01;

    // wait for the host to release the clock
    while (digitalRead(dat) == HIGH);
    while (digitalRead(clk) == LOW);

    // read start bit
    delayMicroseconds(cell/2);
    setLow(clk);
    delayMicroseconds(cell);
    setHigh(clk);
    delayMicroseconds(cell/2);

    // read data bits
    for (int i=0; i<8; i++) {
        if (digitalRead(dat) == HIGH) {
            data = data | (1 << i);
            p = p ^ 1;
        }
        delayMicroseconds(cell/2);
        setLow(clk);
        delayMicroseconds(cell);
        setHigh(clk);
        delayMicroseconds(cell/2);
    }

    // read parity bit
    if (digitalRead(dat) != p) {
        return PARITY;
    }
    delayMicroseconds(cell/2);
    setLow(clk);
    delayMicroseconds(cell);
    setHigh(clk);
    delayMicroseconds(cell/2);

    // send 'ack' bit
    setLow(dat);
    delayMicroseconds(cell/2);
    setLow(clk);
    delayMicroseconds(cell);
    setHigh(clk);
    setHigh(dat);

    // the Arduino has large pull-up resistors so give the data line
    // some time to release
    delayMicroseconds(100);

    *ret = data;
    return SUCCESS;
}
Example #4
0
void TLC5940_Init(void) {
    setOutput(GSCLK_DDR, GSCLK_PIN);
    setOutput(SCLK_DDR, SCLK_PIN);
    setOutput(DCPRG_DDR, DCPRG_PIN);
    setOutput(VPRG_DDR, VPRG_PIN);
    setOutput(XLAT_DDR, XLAT_PIN);
    setOutput(BLANK_DDR, BLANK_PIN);
    setOutput(SIN_DDR, SIN_PIN);

    setLow(GSCLK_PORT, GSCLK_PIN);
    setLow(SCLK_PORT, SCLK_PIN);
    setLow(DCPRG_PORT, DCPRG_PIN);
    setHigh(VPRG_PORT, VPRG_PIN);
    setLow(XLAT_PORT, XLAT_PIN);
    setHigh(BLANK_PORT, BLANK_PIN);
}
/** Main program entry point. This routine configures the hardware required by the application, then
 *  enters a loop to run the application tasks in sequence.
 */
int main(void)
{
	SetupHardware();
setOut(LED_PIN);
	puts_P(PSTR( "Still Image Host Demo running.\r\n" ));

//	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	uint32_t count = 0;
	for (;;)
	{
		Camera_Task();
		USB_USBTask();
		if(count++ >= 1000)
		{
			count = 0;
			if(isOut(LED_PIN) && !isHigh(LED_PIN))
			{
				setHigh(LED_PIN);
			}
			else
			{
				setLow(LED_PIN);
			}
		}
	}
}
Example #6
0
void loop(void)
{
	setHigh(LED);
	delayMs(500);
	setLow(LED);
	delayMs(500);
}
Example #7
0
    NESNumber& NESNumber::operator *= (float k) {
        float result = this->toFloat() * k;
        NESNumber shadow = NESNumber::fromFloat(result);

        setHigh(shadow.getHigh());
        setLow(shadow.getLow());

        return *this;
    }
Example #8
0
// Set direction for Right Motor 0 forward, 1 backward
void setDirectionMotorR(uint8_t dir){

	if(dir){
		setLow(PORTD, BRIDGE_A4);
		TCCR1A &= ~(1 << 4); 
	}else{
		setHigh(PORTD, BRIDGE_A4);
		TCCR1A |= 1 << 4; 
	}
}
Example #9
0
int PS2Emu::hostWrite(unsigned char data) {
    unsigned char p = 0x01;

    // inhibit device transmission
    setLow(clk);
    delayMicroseconds(100);
    // send request to communicate with device
    setLow(dat);
    //delayMicroseconds(cell/2); // could be wrong
    setHigh(clk);

    // send data
    for (int i=0; i<8 ; i++) {
        while (digitalRead(clk) == HIGH);
        if (data & (1 << i)) {
            setHigh(dat);
            p = p ^ 1;
        } else {
            setLow(dat);
        }
        while (digitalRead(clk) == LOW);
    }

    // send parity bit
    while (digitalRead(clk) == HIGH);
    if (p) {
        setHigh(dat);
    } else {
        setLow(dat);
    }
    while (digitalRead(clk) == LOW);

    // send stop bit
    while (digitalRead(clk) == HIGH);
    setHigh(dat);
    while (digitalRead(clk) == LOW);

    // eat the 'ack' bit
    while (digitalRead(clk) == HIGH);
    while (digitalRead(clk) == LOW);

    return SUCCESS;
}
Example #10
0
char battery_status()
{
  char stat = 0;
  setIn(CHARGE_STATUS_PIN);
  setHigh(CHARGE_STATUS_PIN);
  _delay_ms(10);
  if(!getPin(CHARGE_STATUS_PIN)) stat = 1;
  setLow(CHARGE_STATUS_PIN);
  _delay_ms(10);
  if(getPin(CHARGE_STATUS_PIN)) stat = 2;
  return stat;
}
Example #11
0
GPIO::GPIO(LPC1758_GPIO_Type gpioId) :
    mPortNum(gpioId >> __PNSB),
    mPinNum(gpioId & (0xFF >> (8 - __PNSB))) // Should result in (gpioId & 0x1F) if __PNSB is value of 5
{
    uint32_t gpioMemBases[] = { LPC_GPIO0_BASE, LPC_GPIO1_BASE, LPC_GPIO2_BASE, LPC_GPIO3_BASE, LPC_GPIO4_BASE};
    mpOurGpio = (LPC_GPIO_TypeDef*) gpioMemBases[mPortNum];

    // Select GPIO configuration
    volatile uint32_t *pinsel = &(LPC_PINCON->PINSEL0);
    pinsel += (2 * mPortNum);
    *pinsel &= ~(3 << (2*mPinNum));
}

/** @{ Simple functions*/
void GPIO::setAsInput(void)   {   mpOurGpio->FIODIR &= ~(1 << mPinNum);          }
void GPIO::setAsOutput(void)  {   mpOurGpio->FIODIR |= (1 << mPinNum);           }
bool GPIO::read(void) const   {   return !!(mpOurGpio->FIOPIN & (1 << mPinNum)); }
void GPIO::setHigh(void)      {   mpOurGpio->FIOSET = (1 << mPinNum);            }
void GPIO::setLow(void)       {   mpOurGpio->FIOCLR = (1 << mPinNum);            }
void GPIO::set(bool on)       {   (on) ? setHigh() : setLow();                   }
/** @} */

void GPIO::enablePullUp()
{
    volatile uint32_t *pinmode = &(LPC_PINCON->PINMODE0);
    pinmode += (2 * mPortNum);
    *pinmode &= ~(3 << (2*mPinNum));
}
void GPIO::enablePullDown()
{
    volatile uint32_t *pinmode = &(LPC_PINCON->PINMODE0);
    pinmode += (2 * mPortNum);
    *pinmode |= (3 << (2*mPinNum));
}
void GPIO::disablePullUpPullDown()
{
    volatile uint32_t *pinmode = &(LPC_PINCON->PINMODE0);
    pinmode += (2 * mPortNum);
    *pinmode &= ~(3 << (2*mPinNum));
    *pinmode |=  (2 << (2*mPinNum));
}
void GPIO::enableOpenDrainMode(bool openDrain)
{
    volatile uint32_t *pinmode_od = &(LPC_PINCON->PINMODE_OD0);
    pinmode_od += mPortNum;
    if(openDrain) {
        *pinmode_od |= (1 << mPinNum);
    }
    else {
        *pinmode_od &= ~(1 << mPinNum);
    }
}
char hardware_flashlight(char on)
{
    setOut(LED_PIN);
    
    if(on)
    {
        setLow(LED_PIN);
        return 1;
    }
    
    setHigh(LED_PIN);
    return 0;
}
void hardware_init(void)
{
    setOut(POWER_HOLD_PIN); // Hold PWR on
    setLow(POWER_HOLD_PIN);

#ifdef POWER_AUX_PIN
    setOut(POWER_AUX_PIN); // Hold AUX PWR on
    setLow(POWER_AUX_PIN);
#endif

#ifdef USB_ENABLE_PIN
    setOut(USB_ENABLE_PIN); // Hold AUX PWR on
    setLow(USB_ENABLE_PIN);
#endif

    setOut(LED_PIN);  // Red Flashlight
    setHigh(LED_PIN); // off
    setOut(IR_PIN);  // IR Transmitter
    setHigh(IR_PIN); // off

    hardware_USB_Enable();

    hardware_USB_SetDeviceMode();
}
Example #14
0
bool HSV::load() {
	std::ifstream infile;

	char data[100];
	infile.open(DIRECTORY + name + FILE_EXTENSION);
	if (infile.is_open()) {
		infile >> data;
		infile.close();

		std::string content(data);
		std::vector<std::string> v = splitString(content, ';');
		setLow(std::stoi(v[0]), std::stoi(v[1]), std::stoi(v[2]));
		setHigh(std::stoi(v[3]), std::stoi(v[4]), std::stoi(v[5]));

		return true;
	} else {
Example #15
0
void IR::high38(unsigned int time)
{
    uint16_t count = 0;
    
    cli();

    while (count <= time / (1000 / 38))
    {
        setLow(IR_PIN);
        _delay_us((1000 / 38 / 2));
        setHigh(IR_PIN);
        _delay_us((1000 / 38 / 2));
        count++;
    }
    
    sei();
}
Example #16
0
    bool IoGPIO::save(Image & image, JSON & data)
    {
        // ------------------------
        // Trigger the GPIO pin
        
        for(int i = 0; i < m_periods; i++)
        {
            // ---------------------------
            // Put pin high for some time
            
            setHigh();
            usleep(m_periodTime);
            setLow();
            usleep(m_periodTime);
        }

        return true;
    }
Example #17
0
void PlotLine::copy (PlotLine *d)
{
  d->getColor(color);
  
  setType(d->getType());
  
  d->getLabel(label);
  
  setScaleFlag(d->getScaleFlag());

  setColorFlag(d->getColorFlag());

  d->getData(data);

  d->getDateList(dateList);

  setHigh(d->getHigh());
  setLow(d->getLow());
}
Example #18
0
void TLC5940_ClockInDC(void) {
    setHigh(DCPRG_PORT, DCPRG_PIN);
    setHigh(VPRG_PORT, VPRG_PIN);

    uint8_t Counter = 0;

    for (;;) {
        if (Counter > TLC5940_N * 96 - 1) {
            pulse(XLAT_PORT, XLAT_PIN);
            break;
        } else {
            if (dcData[Counter])
                setHigh(SIN_PORT, SIN_PIN);
            else
                setLow(SIN_PORT, SIN_PIN);
            pulse(SCLK_PORT, SCLK_PIN);
            Counter++;
        }
    }
}
void hardware_lightning_enable()
{
    // Need to power off lights //
    backlightVal = lcd.getBacklight();
    lcd.backlight(0);
    
    if(backlightVal > 0) 
        _delay_ms(50);

    setIn(LIGHT_SENSE_PIN); // set to input
    setLow(LIGHT_SENSE_PIN); // no pull-up

    uint8_t i = 3;
    while(i--)
    {
        hardware_light_enable(i);
        _delay_ms(50);
        uint16_t reading = hardware_analogRead(0);
        //DEBUG('(');
        //DEBUG(reading);
        //DEBUG(')');
        //DEBUG(':');
        //DEBUG(' ');
        //DEBUG_NL();
        if(reading < 256) break;
    }
    //DEBUG(i);
    //if(getPin(LIGHT_SENSE_PIN)) {
    //    DEBUG(STR("+"));
    //}
    //else
    //{
    //    DEBUG(STR("-"));
    //}

    shutter_half();
    
    EIMSK &= ~_BV(INT6);      // Interrupt disable 
    EICRB |= (1<<ISC61)|(1<<ISC60); // Rising edge
    EIMSK |= _BV(INT6);      // Interrupt enable 
}
Example #20
0
    bool IoGPIO::save(Image & image, JSON & data)
    {
        if(throttle.canExecute())
        {
            // ------------------------
            // Trigger the GPIO pin

            LINFO << "IoGPIO: triggering GPIO pin " + helper::to_string(m_pin);

            for(int i = 0; i < m_periods; i++)
            {
                // ---------------------------
                // Put pin high for some time

                setHigh();
                usleep(m_periodTime);
                setLow();
                usleep(m_periodTime);
            }
        }

        return true;
    }
Example #21
0
void moveMotor(){
	setLow(PORTD,lastPosition%4+4);
	setHigh(PORTD,currentPosition%4+4);
}
Example #22
0
	// Pulse the pin high. On the SAM3S the pulse is about 400ns wide.
	void pulseLow() const
	{
		setLow();
		setHigh();
	}
Example #23
0
// Initialize the motor control.
void initMotorControl(void){
	// Set the directions.
	setOutput(DDRD, BRIDGE_A1);
	setOutput(DDRD, BRIDGE_A2);
	setOutput(DDRD, BRIDGE_A3);
	setOutput(DDRD, BRIDGE_A4);
	setOutput(DDRD, BRIDGE_EN);
	setInput(DDRD, MOTOR_L_A);
	setInput(DDRD, MOTOR_R_A);


	// Set the initial output values for outputs.
	setLow(PORTD, BRIDGE_A1);
	setHigh(PORTD, BRIDGE_A2);
	setLow(PORTD, BRIDGE_A3);
	setHigh(PORTD, BRIDGE_A4);
	setLow(PORTC, BRIDGE_EN);


	// Initilize Timer/counter 1
	TCCR1A = 0b10100010;
	TCCR1B = 0b00011001;
	// Both PMW outputs set at TOP, clear on compare
	// Waveform generation mode (WGM) set to 14 (fast PWM TOP is ICR1)
	// Input capture noise canceler (ICNC1) disabled, Input capture Edge select (ICES1) set to falling edge.
	// NOTE: when ICR1 is set to TOP the input capture function is disabled thus ICES1 and ICNC1 are cleared.
	// no prescaler is used clk/1

	TCNT1 = 0; 		//reset counter1
	OCR1A = 250; 	//speed of Left Motor 0-250
	OCR1B = 250; 	//speed of Right Motor 0-250
	ICR1 = 250; 	// Top value for TCNT1 defines the freq of the PMW (10MHz / 250 = 40 kHz)


	// Initilize Timer/Counter 0		
	TCCR0 = 0b00001101;
	// WGM CTC, OCR0 is TOP
	// OC0 disconnected.
	// clk/1024 prescaler = 9,765.625 Hz
	
	TCNT0 = 0;	// reset counter0
	OCR0 = 98;	// Counter divisor 9,765.625/98 = 99,64923469 Hz ~ 10 ms period

	// Enabled Timer/Counter0 Compare Match interrupt.
	TIMSK |= 2;


	// External interrupts... 
	//General Interrupt Control Register
	GICR |= 0b11000000;
	// bit 6 = 1 = Enable INT1
	// bit 7 = 1 = Enable INT0

	//MCU Control Register
	MCUCR |= 0b00001111;
	// bit1, bit0 = 11 = positive logical change on INT0 generates an interupt request.
	// bit3, bit2 = 11 = positive logical change on INT1 generates an interupt request

	//MSU Control and Status Register
	MCUCSR |= 0b00000000;

	// General Interrupt Flag Register
	GIFR   |= 0b11000000;
}
Example #24
0
int PS2Emu::devWrite(unsigned char data) {
    unsigned char p = 0x01;;
    int clk_start, clk_stop;

    // clock must be high for 50 microseconds before transmission
    /*
    if (checkState(clk, LOW, 50))
        return INHIBIT;
        */

    // set start bit
    setLow(dat);
    delayMicroseconds(cell/2);
    /*
    if (!checkState(clk, LOW, 100))
      return INHIBIT;
        */
    setLow(clk);
    delayMicroseconds(cell);
    setHigh(clk);
    delayMicroseconds(cell/2);

    // set data bits
    for (int i=0; i<8; i++) {
        if (data & (1 << i)) {
            setHigh(dat);
            p = p ^ 1;
        } else {
            setLow(dat);
        }
        delayMicroseconds(cell/2);
        /*
          if (!checkState(clk, LOW, 100))
            return INHIBIT;
            */
        setLow(clk);
        delayMicroseconds(cell);
        setHigh(clk);
        delayMicroseconds(cell/2);
    }

    // set parity bit
    if (p) {
        setHigh(dat);
    } else {
        setLow(dat);
    }
    delayMicroseconds(cell/2);
    /*
    if (!checkState(clk, LOW, 100))
      return INHIBIT;
        */
    setLow(clk);
    delayMicroseconds(cell);
    setHigh(clk);
    delayMicroseconds(cell/2);

    // stet stop bit
    setHigh(dat);
    delayMicroseconds(cell/2);
    setLow(clk);
    delayMicroseconds(cell);
    setHigh(clk);
    delayMicroseconds(cell/2);

    return SUCCESS;
}
Example #25
0
// Disable outputs on the H-bridge
void disableHBridge(void){
	setLow(PORTC, BRIDGE_EN);
}
Example #26
0
 NESNumber::NESNumber(const float& value) {
     NESNumber converted = NESNumber::fromFloat(value);
     setHigh(converted.getHigh());
     setLow(converted.getLow());
 }
Example #27
0
void IR::shutterDelayed()
{
    if(make == CANON || make == ALL)
    {
        cli();
        
        for(int i = 0; i < 16; i++)
        {
            setLow(IR_PIN);
            _delay_us(15.24);
            setHigh(IR_PIN);
            _delay_us(15.24);
        }
        
        _delay_ms(5.36);
        
        for(int i = 0; i < 16; i++)
        {
            setLow(IR_PIN);
            _delay_us(15.24);
            setHigh(IR_PIN);
            _delay_us(15.24);
        }
        
        sei();
    }

    if(make == MINOLTA || make == ALL)
    {
        bool _seqDelayed[] = {
            0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
        
        high38(3750);
        _delay_ms(1.890);
        
        for(uint8_t i = 0; i < sizeof(_seqDelayed)/sizeof(_seqDelayed[0]); i++)
        {
            if(_seqDelayed[i] == 0)
            {
                high38(456);
                _delay_us(487);
            } else
            {
                high38(456);
                _delay_ms(1.430);
            }
        };
    }

    if(make == SONY || make == ALL)
    {
        bool _seqDelayed[] = {
            1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1 };
        
        for(uint8_t j = 0; j < 3; j++)
        {
            high40(2320);
            _delay_us(650);
            
            for(uint8_t i = 0; i < sizeof(_seqDelayed)/sizeof(_seqDelayed[0]); i++)
            {
                if(_seqDelayed[i] == 0)
                {
                    high40(575);
                } else
                {
                    high40(1175);
                }
                _delay_us(650);
            }
            _delay_ms(10);
        }
    }
}
Example #28
0
 NESNumber::NESNumber(const double& value) {
     NESNumber converted = NESNumber::fromDouble(value);
     setHigh(converted.getHigh());
     setLow(converted.getLow());
 }
Example #29
0
void IR::shutterNow()
{
    if(make == CANON || make == ALL)
    {        
        for(int i = 0; i < 16; i++)
        {
            cli();
            setLow(IR_PIN);
            _delay_us(15.24);
            setHigh(IR_PIN);
            _delay_us(15.24);
            sei();
        }
        
        _delay_ms(7.33);
        
        for(int i = 0; i < 16; i++)
        {
            cli();
            setLow(IR_PIN);
            _delay_us(15.24);
            setHigh(IR_PIN);
            _delay_us(15.24);
            sei();
        }
        
    }

    if(make == NIKON || make == ALL)
    {
        high40(2000);
        _delay_ms(27.830);
        high40(390);
        _delay_ms(1.580);
        high40(410);
        _delay_ms(3.580);
        high40(400);
    }

    if(make == PENTAX || make == ALL)
    {
        high38(13000);
        _delay_ms(3);
        
        for(int i = 0; i < 7; i++)
        {
            high38(1000);
            _delay_ms(1);
        };
    }

    if(make == OLYMPUS || make == ALL)
    {
        bool _seq[] = {
            0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 };
        
        high40(8972);
        _delay_ms(4.384);
        high40(624);
        
        for(uint8_t i = 0; i < sizeof(_seq)/sizeof(_seq[0]); i++)
        {
            if(_seq[i] == 0)
            {
                _delay_us(488);
                high40(600);
            } else
            {
                _delay_ms(1.6);
                high40(600);
            }
        };
    }

    if(make == MINOLTA || make == ALL)
    {
        bool _seq[] = {
            0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1 };
        
        high38(3750);
        _delay_ms(1.890);
        
        for(uint8_t i = 0; i < sizeof(_seq)/sizeof(_seq[0]); i++)
        {
            if(_seq[i] == 0)
            {
                high38(456);
                _delay_us(487);
            } else
            {
                high38(456);
                _delay_ms(1.430);
            }
        };
    }

    if(make == SONY || make == ALL)
    {
        bool _seq[] = {
            1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1 };
        
        for(int j = 0; j < 3; j++)
        {
            high40(2320);
            _delay_us(650);
            
            for(uint8_t i = 0; i < sizeof(_seq)/sizeof(_seq[0]); i++)
            {
                if(_seq[i] == 0)
                {
                    high40(575);
                    _delay_us(650);
                } else
                {
                    high40(1175);
                    _delay_us(650);
                }
            }
            _delay_ms(10);
        }
    }

}