2015-02-20 17:49:56 -07:00
|
|
|
/*
|
|
|
|
* Author: Jon Trulson <jtrulson@ics.com>
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2015-02-20 17:49:56 -07:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-02-20 17:49:56 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2017-08-30 15:00:29 -07:00
|
|
|
|
2016-04-25 14:27:51 -07:00
|
|
|
#include "l298.hpp"
|
2017-08-30 15:00:29 -07:00
|
|
|
#include "upm_utilities.h"
|
2015-02-20 17:49:56 -07:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2017-08-30 15:00:29 -07:00
|
|
|
int
|
|
|
|
main()
|
2015-02-20 17:49:56 -07:00
|
|
|
{
|
2017-08-30 15:00:29 -07:00
|
|
|
//! [Interesting]
|
|
|
|
|
|
|
|
// Instantiate one of the 2 possible DC motors on a L298 Dual
|
|
|
|
// H-Bridge. For controlling a stepper motor, see the l298-stepper
|
|
|
|
// example.
|
|
|
|
upm::L298 l298(3, 4, 7);
|
|
|
|
|
|
|
|
cout << "Starting motor at 50% for 3 seconds..." << endl;
|
|
|
|
l298.setSpeed(50);
|
|
|
|
l298.setDirection(upm::L298::DIR_CW);
|
|
|
|
l298.enable(true);
|
|
|
|
|
|
|
|
upm_delay(3);
|
|
|
|
|
|
|
|
cout << "Reversing direction..." << endl;
|
|
|
|
l298.setDirection(upm::L298::DIR_NONE); // fast stop
|
|
|
|
l298.setDirection(upm::L298::DIR_CCW);
|
|
|
|
upm_delay(3);
|
|
|
|
|
|
|
|
l298.setSpeed(0);
|
|
|
|
l298.enable(false);
|
|
|
|
|
|
|
|
//! [Interesting]
|
|
|
|
|
|
|
|
cout << "Exiting..." << endl;
|
|
|
|
|
|
|
|
return 0;
|
2015-02-20 17:49:56 -07:00
|
|
|
}
|